List of usage examples for javafx.scene.control TextField setText
public final void setText(String value)
From source file:de.pixida.logtest.designer.commons.SelectFileButton.java
public static Button createButtonWithFileSelection(final TextField inputFieldShowingPath, final String icon, final String title, final String fileMask, final String fileMaskDescription) { final Button selectLogFileButton = new Button("Select"); selectLogFileButton.setGraphic(Icons.getIconGraphics(icon)); selectLogFileButton.setOnAction(event -> { final FileChooser fileChooser = new FileChooser(); fileChooser.setTitle(title);/*from w w w . j ava2 s . c om*/ if (StringUtils.isNotBlank(fileMask) && StringUtils.isNotBlank(fileMaskDescription)) { fileChooser.getExtensionFilters() .add(new FileChooser.ExtensionFilter(fileMaskDescription, fileMask)); } File initialDirectory = new File(inputFieldShowingPath.getText().trim()); if (!initialDirectory.isDirectory()) { initialDirectory = initialDirectory.getParentFile(); } if (initialDirectory == null || !initialDirectory.isDirectory()) { if (lastFolder != null) { initialDirectory = lastFolder; } else { initialDirectory = new File("."); } } fileChooser.setInitialDirectory(initialDirectory); final File selectedFile = fileChooser.showOpenDialog(((Node) event.getTarget()).getScene().getWindow()); if (selectedFile != null) { inputFieldShowingPath.setText(selectedFile.getAbsolutePath()); final File parent = selectedFile.getParentFile(); if (parent != null && parent.isDirectory()) { lastFolder = parent; } } }); return selectLogFileButton; }
From source file:fruitproject.FruitProject.java
public void second(final String pfname) { final Stage st = new Stage(); Scene scene = null;// w w w . j av a2 s. c om final GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); TableView tv = new TableView(); final TableColumn<Map, String> firstDataColumn = new TableColumn<>("Name"); final TableColumn<Map, String> secondDataColumn = new TableColumn<>("Amount"); final TableColumn<Map, String> thirdDataColumn = new TableColumn<>("Remove"); firstDataColumn.setMinWidth(130); secondDataColumn.setMinWidth(130); thirdDataColumn.setMinWidth(130); if (!pfname.equals("")) { firstDataColumn.setCellValueFactory(new MapValueFactory(Column1MapKey)); secondDataColumn.setCellValueFactory(new MapValueFactory(Column2MapKey)); thirdDataColumn.setCellValueFactory(new MapValueFactory(Column3MapKey)); rows = 0; tv = new TableView<>(generateDataInMap(pfname, addPairs)); } tv.getColumns().setAll(firstDataColumn, secondDataColumn, thirdDataColumn); // secondDataColumn.setCellFactory(TextFieldTableCell.forTableColumn()); ScrollPane sp = new ScrollPane(); sp.setMinWidth(400); sp.setHbarPolicy(ScrollBarPolicy.NEVER); sp.setContent(tv); grid.add(sp, 0, 3); final ComboBox comboBox = new ComboBox(); HBox hb1 = new HBox(); comboBox.setValue("FILE"); comboBox.getItems().addAll("Save this file", "Load a new file"); Button btnOk = new Button(); btnOk.setText("OK"); hb1.getChildren().addAll(comboBox, btnOk); hb1.setSpacing(10); grid.add(hb1, 0, 1); Label label1 = new Label("Title:"); final TextField tfFilename = new TextField(); tfFilename.setText(getTitle(pfname)); HBox hb = new HBox(); hb.getChildren().addAll(label1, tfFilename); hb.setSpacing(10); grid.add(hb, 0, 2); final Stage ps = new Stage(); final TableView tv1 = tv; btnOk.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); if (comboBox.getValue().equals("Load a new file")) { first(ps); st.close(); } else { PrintWriter pw = null; try { pw = new PrintWriter("abc.json"); BufferedWriter bw = new BufferedWriter(new FileWriter(pfname, false)); bw.write("{title:\"" + tfFilename.getText() + "\""); bw.write(",fruits:["); for (int i = 0; i < rows; i++) { bw.write("{name:\"" + String.valueOf(firstDataColumn.getCellData(i)) + "\",amount:" + String.valueOf(secondDataColumn.getCellData(i)) + "}"); if (i != rows - 1) bw.write(","); } bw.write("]}"); bw.close(); } catch (Exception e) { System.out.println(e.toString()); } } } }); Button btn = new Button(); btn.setText("New Fruit"); grid.add(btn, 1, 2); // TableView tv=new TableView(); // TableColumn Col1 = new TableColumn("Name"); // TableColumn Col2 = new TableColumn("Amount"); // TableColumn Col3 = new TableColumn("Remove"); // tv.getColumns().addAll(Col1, Col2, Col3); //sp.setFitToWidth(true); Image img = new Image("file:music.jpg"); ImageView iv2 = new ImageView(); iv2.setImage(img); iv2.setFitWidth(200); iv2.setPreserveRatio(true); iv2.setSmooth(true); iv2.setCache(true); grid.add(iv2, 1, 3); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); System.out.println(comboBox.valueProperty()); st.close(); third(pfname); } }); scene = new Scene(grid, 700, 450); st.setScene(scene); st.show(); }
From source file:com.github.drbookings.ui.controller.BookingDetailsController.java
private void addRowNetEarnings(final Pane content, final BookingBean be) { final HBox box = new HBox(); box.setSpacing(boxSpacing);/*w w w . ja v a 2s. com*/ box.setPadding(boxPadding); box.setAlignment(Pos.CENTER_LEFT); box.setFillHeight(true); final TextField grossEarningsExpression = new TextField(be.getGrossEarningsExpression()); grossEarningsExpression.setPrefWidth(prefTextInputFieldWidth * 1.5); booking2GrossEarnings.put(be, grossEarningsExpression); final Text grossEarnings = new Text(decimalFormat.format(be.getGrossEarnings())); final TextFlow tf = new TextFlow(new Text("Gross Earnings: "), grossEarningsExpression, new Text(" = "), grossEarnings, new Text("")); box.getChildren().addAll(tf); if (be.getGrossEarnings() <= 0) { box.getStyleClass().addAll("warning", "warning-bg"); } final HBox box2 = new HBox(); box2.setSpacing(boxSpacing); box2.setPadding(boxPadding); box2.setAlignment(Pos.CENTER_LEFT); box2.setFillHeight(true); Text text = new Text("Amount received: "); TextField textField = new TextField(); textField.setText(new NumberStringConverter().toString(be.getPaymentSoFar())); textField.setEditable(false); be.paymentSoFarProperty().addListener((c, o, n) -> { textField.setText(new NumberStringConverter().toString(n)); }); box2.getChildren().addAll(text, textField); content.getChildren().addAll(box, box2); }
From source file:rmblworx.tools.timey.gui.AlarmIntegrationTest.java
/** * Testet//from w w w .j ava 2 s .c om * <ol> * <li>Anlegen eines Alarms per GUI,</li> * <li>Senden des Ereignisses zum Auslsen des Alarms per Backend und</li> * <li>Reaktion der GUI auf das Ereignis.</li> * </ol> */ @Test @Ignore("schlgt derzeit fehl") // TODO public final void testCreateAlarmAndHandleEvent() { /* * Zeitdifferenz, die der Alarm in der Zukunft ausgelst werden soll. * Wert mglichst klein halten, um Test nich unntig lange dauern zu lassen, aber dennoch gro genug, um sicherzustellen, dass * Alarm bis zu diesem Zeitpunkt vollstndig angelegt werden kann. */ final int bufferInSeconds = 2; final String alarmDescription = "relevanter Alarm"; final AlarmController controller = (AlarmController) getController(); final GuiHelper guiHelper = controller.getGuiHelper(); final ITimey facade = guiHelper.getFacade(); // zwei unwichtige Alarme per Fassade hinzufgen final LocalDateTime now = LocalDateTime.now().withNano(0); facade.setAlarm(AlarmDescriptorConverter .getAsAlarmDescriptor(new Alarm(now.minusYears(1), "alter Alarm", "", false))); facade.setAlarm( AlarmDescriptorConverter.getAsAlarmDescriptor(new Alarm(now.plusYears(1), "Zukunftsalarm"))); // relevanten Alarm per GUI hinzufgen final Button alarmAddButton = (Button) stage.getScene().lookup("#alarmAddButton"); click(alarmAddButton); waitForThreads(); final Scene dialogScene = controller.getDialogStage().getScene(); final TimePicker alarmTimePicker = (TimePicker) dialogScene.lookup("#alarmTimePicker"); final TextField alarmDescriptionTextField = (TextField) dialogScene.lookup("#alarmDescriptionTextField"); final Button alarmSaveButton = (Button) dialogScene.lookup("#alarmSaveButton"); Platform.runLater(new Runnable() { public void run() { alarmTimePicker.setValue(alarmTimePicker.getValue().plusSeconds(bufferInSeconds)); alarmDescriptionTextField.setText(alarmDescription); } }); FXTestUtils.awaitEvents(); final MessageHelper messageHelper = mock(MessageHelper.class); guiHelper.setMessageHelper(messageHelper); // Speichern-Schaltflche bettigen click(alarmSaveButton); waitForThreads(); // sicherstellen, dass Ereignis genau einmal fr den korrekten Alarm eintritt und verarbeitet wird verify(messageHelper, timeout(WAIT_FOR_EVENT)).showTrayMessageWithFallbackToDialog(anyString(), eq(alarmDescription), isNull(TrayIcon.class), isA(ResourceBundle.class)); }
From source file:fruitproject.FruitProject.java
public void first(final Stage primaryStage) { GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER);/*ww w .ja v a2 s . c om*/ grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); rows = 0; addPairs.clear(); Text lb = new Text(); lb.setText("J-Fruit"); //lb.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20)); grid.add(lb, 1, 0); final ToggleGroup grp = new ToggleGroup(); RadioButton rb1 = new RadioButton(); rb1.setText("Add Fruit file"); rb1.setUserData("add"); rb1.setToggleGroup(grp); rb1.setSelected(true); grid.add(rb1, 1, 1); RadioButton rb2 = new RadioButton(); rb2.setText("Load Fruit file"); rb2.setUserData("load"); rb2.setToggleGroup(grp); grid.add(rb2, 1, 2); Label label1 = new Label("Enter File Name:"); final TextField tfFilename = new TextField(); final HBox hb = new HBox(); hb.getChildren().addAll(label1, tfFilename); hb.setSpacing(10); hb.setVisible(false); tfFilename.setText(""); grid.add(hb, 1, 3); grp.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { public void changed(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) { if (grp.getSelectedToggle() != null) { // System.out.println(grp.getSelectedToggle().getUserData().toString()); if (grp.getSelectedToggle().getUserData().toString() == "load") hb.setVisible(true); else { hb.setVisible(false); tfFilename.setText(""); } } } }); if (rb2.isSelected() == true) { hb.setVisible(true); } Button btn = new Button(); btn.setText("GO"); grid.add(btn, 1, 4); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); if (tfFilename.getText() == "") second(""); else second(tfFilename.getText()); primaryStage.close(); } }); //StackPane root = new StackPane(); //root.getChildren().add(lb); //root.getChildren().add(rb1); //root.getChildren().add(rb2); //root.getChildren().add(btn); Scene scene = new Scene(grid, 400, 450); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); }
From source file:com.core.meka.SOMController.java
private void borrar(TextField... fields) { for (TextField t : fields) { t.setText(""); } }
From source file:net.rptools.tokentool.util.FileSaveUtil.java
public File getFileName(boolean asToken, boolean useNumbering, String tempFileName, TextField fileNameSuffix) throws IOException { final String _extension; _extension = AppConstants.DEFAULT_IMAGE_EXTENSION; if (useNumbering) { int dragCounter; try {/*from w w w . j a v a2 s. com*/ dragCounter = Integer.parseInt(fileNameSuffix.getText()); } catch (NumberFormatException e) { dragCounter = 0; } String leadingZeroes = "%0" + fileNameSuffix.getLength() + "d"; fileNameSuffix.setText(String.format(leadingZeroes, dragCounter + 1)); if (tempFileName.isEmpty()) tempFileName = AppConstants.DEFAULT_TOKEN_NAME; if (lastFile != null) { return new File(lastFile.getParent(), String.format("%s_" + leadingZeroes + _extension, tempFileName, dragCounter)); } else { return new File(String.format("%s_" + leadingZeroes + _extension, tempFileName, dragCounter)); } } else { if (lastFile != null) if (tempFileName.isEmpty()) tempFileName = AppConstants.DEFAULT_TOKEN_NAME + _extension; if (!tempFileName.endsWith(_extension)) tempFileName += _extension; if (lastFile != null) lastFile = new File(lastFile.getParent(), tempFileName); else lastFile = new File(tempFileName); return lastFile; } }
From source file:io.bitsquare.gui.components.paymentmethods.BankForm.java
protected void addHolderNameAndIdForDisplayAccount() { String countryCode = bankAccountContractData.getCountryCode(); if (BankUtil.isHolderIdRequired(countryCode)) { Tuple4<Label, TextField, Label, TextField> tuple = addLabelTextFieldLabelTextField(gridPane, ++gridRow, "Account holder name:", BankUtil.getHolderIdLabel(countryCode)); TextField holderNameTextField = tuple.second; holderNameTextField.setText(bankAccountContractData.getHolderName()); holderNameTextField.setMinWidth(300); tuple.forth.setText(bankAccountContractData.getHolderTaxId()); } else {/*from w w w. j av a 2 s. c o m*/ addLabelTextField(gridPane, ++gridRow, "Account holder name:", bankAccountContractData.getHolderName()); } }
From source file:io.bitsquare.gui.components.paymentmethods.CashDepositForm.java
protected void addHolderNameAndIdForDisplayAccount() { String countryCode = cashDepositAccountContractData.getCountryCode(); if (BankUtil.isHolderIdRequired(countryCode)) { Tuple4<Label, TextField, Label, TextField> tuple = addLabelTextFieldLabelTextField(gridPane, ++gridRow, "Account holder name:", BankUtil.getHolderIdLabel(countryCode)); TextField holderNameTextField = tuple.second; holderNameTextField.setText(cashDepositAccountContractData.getHolderName()); holderNameTextField.setMinWidth(300); tuple.forth.setText(cashDepositAccountContractData.getHolderTaxId()); } else {/*from w w w.ja v a 2s . c o m*/ addLabelTextField(gridPane, ++gridRow, "Account holder name:", cashDepositAccountContractData.getHolderName()); } }
From source file:de.pixida.logtest.designer.logreader.LogReaderEditor.java
private TextField createIntegerInputField(final TextField textInput, final Supplier<Integer> getter, final Consumer<Integer> setter) { final TextField integerInput = new TextField(getter.get() == null ? "" : String.valueOf(getter.get())); integerInput.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> { if (!newValue.matches("\\d*")) { integerInput.setText(newValue.replaceAll("[^\\d]", "")); newValue = textInput.getText(); }/*from ww w.j ava 2 s . c o m*/ if (StringUtils.isNotBlank(newValue)) { try { setter.accept(Integer.parseInt(newValue)); } catch (final NumberFormatException nfe) { // This can only happen if the value is "too long" / too high for "int" integerInput.setText(String.valueOf(Integer.MAX_VALUE)); setter.accept(Integer.MAX_VALUE); } } else { setter.accept(null); } this.setChanged(true); }); final double maxWidthOfIntegerInput = 80d; integerInput.setMaxWidth(maxWidthOfIntegerInput); return integerInput; }