public void init() { try { // data init loginId.setText("" + cfg.REQPARAM_SRC_LOGIN_ID); password.setText("" + cfg.REQPARAM_SRC_PASSWORD); // ui init setLayout(new GridLayout(2, 1)); Panel inputArea = new Panel(new BorderLayout(2, 2)); inputArea.add(contactList, "Center"); Panel bottomR = new Panel(new FlowLayout(FlowLayout.RIGHT)); bottomR.add(loginBtn); bottomR.add(logoutBtn); bottomR.add(closeBtn); Panel bottomL = new Panel(new FlowLayout()); bottomL.add(new Label("status:")); bottomL.add(clientStatus); bottomL.add(new Label(" contact:")); bottomL.add(contactListEntry); bottomL.add(addToContactList); bottomL.add(removeFromContactList); bottomL.add(getUserDetailsButton()); bottomL.add(getSendContactsButton()); Panel bottom = new Panel(new BorderLayout()); bottom.add("Center", bottomR); bottom.add("West", bottomL); inputArea.add(bottom, "South"); Panel leftTop = new Panel(new GridLayout(10, 1)); leftTop.add(new Label("login id:")); // 1 leftTop.add(loginId); // 2 leftTop.add(new Label("password:"******"")); leftTop.add(new Label("")); // 6 leftTop.add(new Label("send msg")); leftTop.add(sendMsg); // 8 leftTop.add(new Label("to")); leftTop.add(dstLoginId); // 10 Panel left = new Panel(new FlowLayout()); left.add(leftTop); inputArea.add(left, "West"); Panel eventLogPanel = new Panel(new BorderLayout()); eventLogPanel.add("Center", eventLog); Panel eventLogPanelButtons = new Panel(new FlowLayout(FlowLayout.RIGHT)); eventLogPanelButtons.add(clearEventLogBtn); eventLogPanel.add("South", eventLogPanelButtons); add(inputArea); add(eventLogPanel); setBackground(SystemColor.control); doLayout(); sendMsg.requestFocus(); } catch (Throwable tr) { CAT.error("exception", tr); System.exit(1); } }
public static EventHandler<ActionEvent> getBrowseHandler( FXController controller, TextField filePath) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Select a file to upload..."); return e -> { if (AESCTR.secretKey == null) { new Alert(Alert.AlertType.INFORMATION, "Please generate or choose a key", ButtonType.OK) .showAndWait(); return; } selectedFiles = fileChooser.showOpenMultipleDialog(null); if (selectedFiles != null) { controller.writeLog("Selected files: "); StringBuilder sb = new StringBuilder(1024); for (int i = 0; i < selectedFiles.size(); i++) { if (i == selectedFiles.size() - 1) { sb.append(selectedFiles.get(i).getAbsolutePath()); } else { sb.append(selectedFiles.get(i).getAbsolutePath() + ", "); } controller.writeLog(selectedFiles.get(i).getName()); } filePath.setText(sb.toString()); } }; }
@Override public void initialize(URL location, ResourceBundle resources) { urlField.setOnAction( event -> { String text = urlField.getText(); urlField.setText("tetetetetetetete"); webView.getEngine().load(text); }); webView .getEngine() .getLoadWorker() .stateProperty() .addListener( (ov, oldState, newState) -> { if (newState == State.SUCCEEDED) { String url = webView.getEngine().getLocation(); urlField.setText(url); if (Pattern.compile("http://item.rakuten.co.jp/.*").matcher(url).find()) { try { Elements tmp; Document document = Jsoup.connect(url).get(); tmp = document.select("input"); tmp = tmp.select("#etime"); if (tmp.size() != 0) { if (!(Long.parseLong(tmp.first().val()) < new Date().getTime())) { entryButton.setDisable(false); } } else { entryButton.setDisable(false); } } catch (Exception e) { // TODO 自動生成された catch ブロック e.printStackTrace(); } } } ; }); entryButton.setOnAction( event -> { urlField.setText("webView disable"); sendEntryTaskController(); }); }
public void newFile() { infoTa.setText(""); selectProviderCb.setValue(providers.get(0).getName()); weightTf.setText("0.0"); for (Entry<String, TextField> entry : propertiesTf.entrySet()) { String propertyName = entry.getKey(); TextField tf = entry.getValue(); CheckBox cb = propertiesCb.get(propertyName); tf.setText("0.0"); tf.setDisable(true); cb.setSelected(false); } file = null; mainStage.setTitle("unknown"); }
public synchronized void adjustmentValueChanged(AdjustmentEvent e) { Object source = e.getSource(); for (int i = 0; i < slider.size(); i++) { if (source == slider.elementAt(i)) { Scrollbar sb = (Scrollbar) source; TextField tf = (TextField) numberField.elementAt(sliderIndexes[i]); int digits = sliderScales[i] == 1.0 ? 0 : 2; tf.setText("" + IJ.d2s(sb.getValue() / sliderScales[i], digits)); } } }
public void open(File f) { Properties open = new Properties(); InputStream input = null; try { input = new FileInputStream(f); open.load(input); selectProviderCb.setValue(open.getProperty("provider")); selectGrainCb.setValue(open.getProperty("grain")); weightTf.setText(open.getProperty("weight")); infoTa.setText(open.getProperty("info")); for (Entry<String, TextField> entry : propertiesTf.entrySet()) { String propertyName = entry.getKey(); TextField tf = entry.getValue(); CheckBox cb = propertiesCb.get(propertyName); tf.setText(open.getProperty(propertyName)); if (open.getProperty(propertyName + "_ENABLED").equals("ON")) { tf.setDisable(false); cb.setSelected(true); } else { tf.setDisable(true); cb.setSelected(false); } } mainStage.setTitle(f.getName()); } catch (Exception ex) { infoTa.setText("Не могу открыть файл"); } finally { if (input != null) { try { input.close(); } catch (IOException e) { e.printStackTrace(); } } } }
// load the images when the applet begins executing public void init() { int i; this.processHTMLParameters(); if (totalImages == 0 || imageName == null) { this.showStatus("Invalid parameters"); this.destroy(); } images = new Vector(totalImages, 1); imageTracker = new MediaTracker(this); for (i = 0; i < totalImages; i++) { images.addElement(this.getImage(this.getDocumentBase(), "images/" + imageName + i + ".gif")); // track loading image imageTracker.addImage((Image) images.elementAt(i), i); } // wait for the first image, // must use a Joos version of tracker to avoid catching // interruped exception new JoosMediaTracker(imageTracker).waitForID(0); width = ((Image) images.elementAt(0)).getWidth(this); height = ((Image) images.elementAt(0)).getHeight(this); this.resize(width, height + 30); buffer = this.createImage(width, height); gContext = buffer.getGraphics(); // set background of buffer to white gContext.setColor(c.white()); gContext.fillRect(0, 0, 160, 80); this.setLayout(new BorderLayout(10, 10)); sleepLabel = new Label("Sleep time", c.LABEL_CENTER()); sleepDisplay = new TextField("", 5); sleepDisplay.setText(new Integer(sleepTime).toString()); sleepStuff = new Panel(); sleepStuff.add(sleepLabel); sleepStuff.add(sleepDisplay); new JoosContainer(this).addString("South", sleepStuff); }
public void textValueChanged(TextEvent e) { Object source = e.getSource(); double newXScale = xscale; double newYScale = yscale; if (source == xField && fieldWithFocus == xField) { String newXText = xField.getText(); newXScale = Tools.parseDouble(newXText, 0); if (newXScale == 0) return; if (newXScale != xscale) { int newWidth = (int) (newXScale * r.width); widthField.setText("" + newWidth); if (constainAspectRatio) { yField.setText(newXText); int newHeight = (int) (newXScale * r.height); heightField.setText("" + newHeight); } } } else if (source == yField && fieldWithFocus == yField) { String newYText = yField.getText(); newYScale = Tools.parseDouble(newYText, 0); if (newYScale == 0) return; if (newYScale != yscale) { int newHeight = (int) (newYScale * r.height); heightField.setText("" + newHeight); } } else if (source == widthField && fieldWithFocus == widthField) { int newWidth = (int) Tools.parseDouble(widthField.getText(), 0.0); if (newWidth != 0) { int newHeight = (int) (newWidth * (double) r.height / r.width); heightField.setText("" + newHeight); xField.setText("-"); yField.setText("-"); newXScale = 0.0; newYScale = 0.0; } } xscale = newXScale; yscale = newYScale; }
public static void setJar(final Tile node) { node.data.put("type", "Jar"); List<Node> toRemove = new ArrayList<>(); for (Node n : node.node.getChildren()) { if (!n.getId().equals("delete")) { if (n.getId().equals("typeLabel")) { Label l = (Label) n; l.setText("jar"); l.setTranslateY(l.getTranslateY() - 1); } else { toRemove.add(n); } } } VBox leftPadding = new VBox(); leftPadding.setPrefWidth(14); VBox buttons = new VBox(); VBox textBoxes = new VBox(); VBox extra = new VBox(); buttons.setSpacing(5); textBoxes.setSpacing(5); extra.setSpacing(5); buttons.setPadding(new Insets(7, 0, 0, 0)); textBoxes.setPadding(new Insets(7, 0, 0, 0)); extra.setPadding(new Insets(7, 0, 0, 0)); textBoxes.setTranslateX(17); extra.setTranslateX(32); node.node.getChildren().removeAll(toRemove); final String name = "Package Name"; final String name2 = "Jar Name"; Button findPkg = new Button(); final TextField pkgText = new TextField(); final TextField jarName = new TextField(); findPkg.getStyleClass().add("defaultButton"); findPkg.setText("Find Package Name"); findPkg.setPrefHeight(25); findPkg.setTranslateX(12); findPkg.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { String mainClassName = Util.packageNameFromTile(); if (mainClassName != null) { pkgText.setText(mainClassName); } } }); pkgText.setText(name); pkgText.setPrefSize(150, 27); pkgText.setFont(Font.font("Segoe UI")); pkgText.setId("textBox"); pkgText .textProperty() .addListener( new ChangeListener<String>() { @Override public void changed( ObservableValue<? extends String> observable, String oldValue, String newValue) { node.data.put("package", pkgText.getText().trim()); } }); pkgText .focusedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue == true && pkgText.getText().equals(name)) { pkgText.setText(""); } else if (newValue == false && pkgText.getText().trim().equals("")) { pkgText.setText(name); } } }); jarName.setText(name2); jarName.setPrefSize(150, 27); jarName.setFont(Font.font("Segoe UI")); jarName.setId("textBox"); jarName .textProperty() .addListener( new ChangeListener<String>() { @Override public void changed( ObservableValue<? extends String> observable, String oldValue, String newValue) { node.data.put("jarname", jarName.getText().trim()); } }); jarName .focusedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue == true && jarName.getText().equals(name2)) { jarName.setText(""); } else if (newValue == false && jarName.getText().trim().equals("")) { jarName.setText(name2); } } }); final String defTxt = "Additional Flags"; final TextField flags = new TextField(); flags.setText(defTxt); flags.setPrefSize(150, 27); flags.setFont(Font.font("Segoe UI")); flags.setId("textBox"); flags .focusedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue == true && flags.getText().equals(defTxt)) { flags.setText(""); } else if (newValue == false && flags.getText().trim().equals("")) { flags.setText(defTxt); } } }); flags .textProperty() .addListener( new ChangeListener<String>() { @Override public void changed( ObservableValue<? extends String> observable, String oldValue, String newValue) { node.data.put("flags", flags.getText().trim()); } }); final String defTxt2 = "Output Directory"; final TextField outputDir = new TextField(); outputDir.setText(defTxt2); outputDir.setPrefSize(150, 27); outputDir.setFont(Font.font("Segoe UI")); outputDir.setId("textBox"); outputDir .focusedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue == true && outputDir.getText().equals(defTxt2)) { outputDir.setText(""); } else if (newValue == false && outputDir.getText().trim().equals("")) { outputDir.setText(defTxt2); } } }); outputDir .textProperty() .addListener( new ChangeListener<String>() { @Override public void changed( ObservableValue<? extends String> observable, String oldValue, String newValue) { node.data.put("output", outputDir.getText().trim()); } }); buttons.getChildren().addAll(findPkg); textBoxes.getChildren().addAll(pkgText, jarName); extra.getChildren().addAll(flags, outputDir); node.node.getChildren().addAll(leftPadding, buttons, textBoxes, extra); }
public void textValueChanged(TextEvent e) { Object source = e.getSource(); double newXScale = xscale; double newYScale = yscale; double newZScale = zscale; if (source == xField && fieldWithFocus == xField) { String newXText = xField.getText(); newXScale = Tools.parseDouble(newXText, 0); if (newXScale == 0) return; if (newXScale != xscale) { int newWidth = (int) (newXScale * r.width); widthField.setText("" + newWidth); if (constainAspectRatio) { yField.setText(newXText); int newHeight = (int) (newXScale * r.height); heightField.setText("" + newHeight); } } } else if (source == yField && fieldWithFocus == yField) { String newYText = yField.getText(); newYScale = Tools.parseDouble(newYText, 0); if (newYScale == 0) return; if (newYScale != yscale) { int newHeight = (int) (newYScale * r.height); heightField.setText("" + newHeight); } } else if (source == zField && fieldWithFocus == zField) { String newZText = zField.getText(); newZScale = Tools.parseDouble(newZText, 0); if (newZScale == 0) return; if (newZScale != zscale) { int nSlices = imp.getStackSize(); if (imp.isHyperStack()) { int slices = imp.getNSlices(); int frames = imp.getNFrames(); if (slices == 1 && frames > 1) nSlices = frames; else nSlices = slices; } int newDepth = (int) (newZScale * nSlices); depthField.setText("" + newDepth); } } else if (source == widthField && fieldWithFocus == widthField) { int newWidth = (int) Tools.parseDouble(widthField.getText(), 0.0); if (newWidth != 0) { int newHeight = (int) (newWidth * (double) r.height / r.width); heightField.setText("" + newHeight); xField.setText("-"); yField.setText("-"); newXScale = 0.0; newYScale = 0.0; } } else if (source == depthField && fieldWithFocus == depthField) { int newDepth = (int) Tools.parseDouble(depthField.getText(), 0.0); if (newDepth != 0) { zField.setText("-"); newZScale = 0.0; } } xscale = newXScale; yscale = newYScale; zscale = newZScale; }
@Override public void initialize(URL location, ResourceBundle resources) { AppController.instance = this; this.res = resources; ObservableList<String> modeItems = FXCollections.observableArrayList( Settings.MODE_NEXT, Settings.MODE_RANDOM, Settings.MODE_SAME); modeList.setItems(modeItems); modeList.getSelectionModel().select(Settings.currentMode); modeList .valueProperty() .addListener( (ObservableValue ov, Object oldVal, Object newVal) -> { Settings.currentMode = (String) newVal; }); setupPlaylistsView(); setupPlaylistsContextMenu(); setupTracksView(); tracksView.setContextMenu(tracksContextMenu); tracksView.setOnContextMenuRequested( (ContextMenuEvent evt) -> { setupTracksContextMenu(); evt.consume(); }); tracksView .getSelectionModel() .selectedItemProperty() .addListener( (ObservableValue observable, Object oldValue, Object newValue) -> { Settings.lastTrackId = newValue != null ? ((Track) newValue).getId() : null; }); playlistsView .getSelectionModel() .selectedItemProperty() .addListener( (ObservableValue observable, Object oldValue, Object newValue) -> { loadSelectedPlaylist(); Settings.lastPlaylistId = newValue != null ? ((Playlist) newValue).getId() : null; searching = false; searchText.setText(StringUtils.EMPTY); }); volumeSlider.setCursor(Cursor.HAND); volumeSlider .valueProperty() .addListener( (ObservableValue<? extends Number> ov, Number oldVal, Number newVal) -> { if (player != null) { player.setVolume(newVal.doubleValue()); } Settings.currentVolume = newVal.doubleValue(); volumeLabel.setText( String.valueOf((int) Math.ceil(newVal.doubleValue() * 100)) + "%"); }); volumeSlider.setValue(Settings.currentVolume); imagePlay = new ImageView(new Image(getClass().getResourceAsStream("/images/button_play.png"))); imagePlay.setScaleX(0.40); imagePlay.setScaleY(0.40); imagePause = new ImageView(new Image(getClass().getResourceAsStream("/images/button_pause.png"))); imagePause.setScaleX(0.5); imagePause.setScaleY(0.5); imageSettings = new ImageView(new Image(getClass().getResourceAsStream("/images/settings.png"))); imageSettings.setScaleX(0.5); imageSettings.setScaleY(0.5); imageUpdate = new ImageView(new Image(getClass().getResourceAsStream("/images/refresh.png"))); imageUpdate.setScaleX(0.5); imageUpdate.setScaleY(0.5); imageAdd = new ImageView(new Image(getClass().getResourceAsStream("/images/add.png"))); imageAdd.setScaleX(0.5); imageAdd.setScaleY(0.5); imageRename = new ImageView(new Image(getClass().getResourceAsStream("/images/rename.png"))); imageRename.setScaleX(0.5); imageRename.setScaleY(0.5); imageDelete = new ImageView(new Image(getClass().getResourceAsStream("/images/delete.png"))); imageDelete.setScaleX(0.5); imageDelete.setScaleY(0.5); stateButton.setGraphic(imagePlay); settingsButton.setGraphic(imageSettings); refreshButton.setGraphic(imageUpdate); refreshButton.setTooltip(new Tooltip(res.getString("tooltip_sync"))); addButton.setGraphic(imageAdd); addButton.setOnAction((evt) -> createOfflinePlaylist()); addButton.setTooltip(new Tooltip(res.getString("tooltip_add_offline"))); renameButton.setGraphic(imageRename); renameButton.setOnAction(evt -> renamePlaylist()); renameButton.setTooltip(new Tooltip(res.getString("rename_playlist"))); deleteButton.setGraphic(imageDelete); deleteButton.setOnAction(evt -> deletePlaylist()); deleteButton.setTooltip(new Tooltip(res.getString("delete_playlist"))); loadProgressBar.setCursor(Cursor.HAND); volumeSlider.setCursor(Cursor.HAND); updatePlaylists(); if (Settings.lastPlaylistId != null) { currentPlaylist = ((ObservableList<Playlist>) playlistsView.getItems()) .stream() .filter((playlist) -> playlist.getId().equals(Settings.lastPlaylistId)) .findFirst() .orElse(null); playlistsView.getSelectionModel().select(currentPlaylist); playlistsView.scrollTo(currentPlaylist); Platform.runLater( () -> { if (Settings.lastTrackId != null) { currentTrack = ((ObservableList<Track>) tracksView.getItems()) .stream() .filter((track) -> track.getId().equals(Settings.lastTrackId)) .findFirst() .orElse(null); tracksView.getSelectionModel().select(currentTrack); tracksView.scrollTo(currentTrack); } }); } new Timer() .scheduleAtFixedRate( new TimerTask() { @Override public void run() { updatePlayProgress(); } }, 100, 100); setupTracksContextMenu(); setupShortcuts(); Platform.runLater( () -> { tracksView.requestFocus(); }); }
public GuiClient() { setLayout(new FlowLayout()); /** ** We define the textfields and buttons****** */ lbIP = new Label("Enter the IP address of the server: "); // Construct Label add(lbIP); tfIP = new TextField(110); // Construct TextField add(tfIP); // "super" Frame adds TextField tfIP.setText("10.16.31.163"); // Set a default value tfIP.addActionListener(this); // Hitting Enter on TextField fires ActionEvent // tfInput (TextField) registers this instance as ActionEvent listener lblInput = new Label("Enter a link below: "); add(lblInput); tfInput = new TextField(110); add(tfInput); tfInput.setText("http://vodlocker.com/budq9rt5wt0e"); tfInput.addActionListener(this); lblOutput = new Label("The download link is below: "); add(lblOutput); tfOutput = new TextField(110); tfOutput.setEditable(false); // read-only add(tfOutput); /** ************Stream************** */ Butstr = new Button("Stream"); // construct Button add(Butstr); // "super" Frame adds Button Butstr.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { streamvidlink(getvidlink()); tfOutput.setText("The video is being streamed"); } }); /** ************Download************** */ Butdow = new Button("Download"); add(Butdow); Butdow.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { downvidlink(getvidlink()); tfOutput.setText("The video is being downloaded"); } }); /** ************QR CODE************** */ Butqr = new Button("Qr Code"); add(Butqr); Butqr.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // we load the qrvidlink() function that saves the image locally qrvidlink(); try { // we display the image that is saved Runtime.getRuntime().exec("display qrcode.png"); tfOutput.setText("The Qr code will be generated"); } catch (Exception ex) { System.out.println("Qr Code failed: " + ex); } } }); setTitle("Client"); // "super" Frame sets title setSize(900, 400); // "super" Frame sets initial window size setVisible(true); // "super" Frame shows }
/** **************************************************************** */ @Override public void actionPerformed(ActionEvent evt) { vlink = getvidlink(); // it gets the video link from the text input tfOutput.setText(vlink); // and tries to set the direct link to the video }