List of usage examples for javafx.scene.control TextField TextField
public TextField()
From source file:de.perdoctus.ebikeconnect.gui.dialogs.LoginDialog.java
@PostConstruct public void init() { final ImageView graphic = new ImageView( new Image(getClass().getResource("/app-icon.png").toExternalForm())); graphic.setPreserveRatio(true);/*from w w w . j a v a 2s . c om*/ graphic.setFitHeight(64); setGraphic(graphic); setResizable(true); setWidth(400); setResizable(false); setTitle(rb.getString("dialogTitle")); setHeaderText(rb.getString("dialogMessage")); final ButtonType loginButtonType = new ButtonType(rb.getString("loginButton"), ButtonBar.ButtonData.OK_DONE); getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); // Create the username and password labels and fields. final GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 10, 10, 10)); grid.setPrefWidth(getWidth()); grid.getColumnConstraints().add(new ColumnConstraints(-1, -1, -1, Priority.NEVER, HPos.LEFT, true)); grid.getColumnConstraints().add(new ColumnConstraints(-1, -1, -1, Priority.ALWAYS, HPos.LEFT, true)); final String rbUsername = rb.getString(CFG_USERNAME); final TextField txtUsername = new TextField(); txtUsername.setPromptText(rbUsername); txtUsername.setText(config.getString(CFG_USERNAME, "")); final Label lblUsername = new Label(rbUsername); lblUsername.setLabelFor(txtUsername); grid.add(lblUsername, 0, 0); grid.add(txtUsername, 1, 0); final String rbPassword = rb.getString(CFG_PASSWORD); final PasswordField txtPassword = new PasswordField(); txtPassword.setPromptText(rbPassword); if (config.getBoolean(CFG_SAVE_PASSWORD, false)) { txtPassword.setText(config.getString(CFG_PASSWORD, "")); } final Label lblPassword = new Label(rbPassword); lblPassword.setLabelFor(txtPassword); grid.add(lblPassword, 0, 1); grid.add(txtPassword, 1, 1); final CheckBox cbSavePassword = new CheckBox(rb.getString("save-password")); cbSavePassword.setSelected(config.getBoolean(CFG_SAVE_PASSWORD, false)); grid.add(cbSavePassword, 1, 2); getDialogPane().setContent(grid); // Enable/Disable login button depending on whether a username was entered. final Node loginButton = getDialogPane().lookupButton(loginButtonType); loginButton.disableProperty() .bind(txtUsername.textProperty().isEmpty().or(txtPassword.textProperty().isEmpty())); setResultConverter(buttonType -> { if (buttonType == loginButtonType) { config.setProperty(CFG_USERNAME, txtUsername.getText()); config.setProperty(CFG_SAVE_PASSWORD, cbSavePassword.isSelected()); if (cbSavePassword.isSelected()) { config.setProperty(CFG_PASSWORD, txtPassword.getText()); config.setProperty(CFG_PASSWORD, txtPassword.getText()); } else { config.clearProperty(CFG_PASSWORD); } return new Credentials(txtUsername.getText(), txtPassword.getText()); } else { return null; } }); if (txtUsername.getText().isEmpty()) { txtUsername.requestFocus(); } else { txtPassword.requestFocus(); txtPassword.selectAll(); } }
From source file:com.playonlinux.javafx.mainwindow.library.ViewLibrary.java
@Override protected void drawSideBar() { searchBar = new TextField(); searchBar.setOnKeyReleased(event -> applyFilter(searchBar.getText())); this.runScript = new LeftButton("/com/playonlinux/javafx/mainwindow/library/script.png", translate("Run a script")); this.runConsole = new LeftButton("/com/playonlinux/javafx/mainwindow/library/console.png", translate("${application.name} console")); LeftSpacer spacer = new LeftSpacer(); addToSideBar(searchBar, spacer, new LeftBarTitle("Advanced tools"), runScript, runConsole); super.drawSideBar(); }
From source file:gov.va.isaac.gui.preferences.plugins.properties.PreferencesPluginTextFieldProperty.java
public PreferencesPluginTextFieldProperty(Label label, boolean emptyStringAllowed) { super(label, new TextField(), new SimpleStringProperty(), null, // validator handled below new StringConverter<String>() { @Override/*from ww w . j a va 2 s . com*/ public String convertToString(String value) { return value != null ? value.toString() : null; } }, new PropertyAction<String, TextField>() { @Override public void apply(PreferencesPluginProperty<String, TextField> property) { property.getProperty().bind(property.getControl().textProperty()); } }, new PropertyAction<String, TextField>() { @Override public void apply(PreferencesPluginProperty<String, TextField> property) { property.getControl().textProperty().set(property.readFromPersistedPreferences()); } }, new PropertyAction<String, TextField>() { @Override public void apply(PreferencesPluginProperty<String, TextField> property) { GridPane.setHgrow(property.getLabel(), Priority.NEVER); GridPane.setFillWidth(property.getControl(), true); GridPane.setHgrow(property.getControl(), Priority.ALWAYS); } }); validator = new ValidBooleanBinding() { { bind(getProperty()); setComputeOnInvalidate(true); } @Override protected boolean computeValue() { if (!emptyStringAllowed && StringUtils.isBlank(getProperty().getValue())) { this.setInvalidReason("unspecified value for " + name); logger.debug(getReasonWhyInvalid().get()); TextErrorColorHelper.setTextErrorColor(label); return false; } else { TextErrorColorHelper.clearTextErrorColor(label); } this.clearInvalidReason(); return true; } }; }
From source file:account.management.controller.inventory.InsertStockController.java
public void addRow() { ComboBox<Product> select_item = new ComboBox(); select_item.setPromptText("Select Item"); select_item.setPrefWidth(190);//from www .ja v a 2s .c o m select_item.setPrefHeight(25); new AutoCompleteComboBoxListener<>(select_item); select_item.setOnHiding((e) -> { Product a = select_item.getSelectionModel().getSelectedItem(); select_item.setEditable(false); select_item.getSelectionModel().select(a); }); select_item.setOnShowing((e) -> { select_item.setEditable(true); }); TextField qty = new TextField(); qty.setPromptText("Quantity"); qty.setPrefWidth(97); qty.setPrefHeight(25); TextField rate = new TextField(); rate.setPrefWidth(100); rate.setPrefHeight(25); if (this.voucher_type.getSelectionModel().getSelectedItem().equals("Purchase")) { rate.setPromptText("Purchase Rate"); } else { rate.setPromptText("Sell Rate"); } Button del = new Button("Delete"); HBox row = new HBox(); row.getChildren().addAll(select_item, qty, rate, del); row.setSpacing(10); row.setPadding(new Insets(0, 0, 0, 15)); this.conatiner.getChildren().add(row); del.setOnAction((e) -> { this.conatiner.getChildren().remove(row); this.add_row.setDisable(false); calculateTotal(); }); select_item.getItems().addAll(this.products_list); select_item.setOnAction((e) -> { qty.setText("0"); if (this.voucher_type.getSelectionModel().getSelectedItem().equals("Purchase")) { rate.setText(String.valueOf(select_item.getSelectionModel().getSelectedItem().getLast_p_rate())); } else { rate.setText(String.valueOf(select_item.getSelectionModel().getSelectedItem().getLast_s_rate())); } calculateTotal(); }); qty.setOnKeyReleased((e) -> { calculateTotal(); }); rate.setOnKeyReleased((e) -> { calculateTotal(); }); if (this.conatiner.getChildren().size() >= 8) { this.add_row.setDisable(true); return; } }
From source file:fruitproject.FruitProject.java
public void first(final Stage primaryStage) { GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER);//from w ww .j a va 2 s . c o m 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.panemu.tiwulfx.table.LookupColumn.java
private SearchMenuItemBase<C> getLookupMenuItem() { if (searchMenuItem == null) { searchInputControl = new TextField(); searchMenuItem = new SearchMenuItemBase<C>(this) { @Override//from w ww .j a v a 2 s .c o m protected Node getInputControl() { return searchInputControl; } @Override protected List<TableCriteria.Operator> getOperators() { List<TableCriteria.Operator> lst = new ArrayList<>(); lst.add(TableCriteria.Operator.eq); lst.add(TableCriteria.Operator.ne); lst.add(TableCriteria.Operator.ilike_begin); lst.add(TableCriteria.Operator.ilike_anywhere); lst.add(TableCriteria.Operator.ilike_end); lst.add(TableCriteria.Operator.lt); lst.add(TableCriteria.Operator.le); lst.add(TableCriteria.Operator.gt); lst.add(TableCriteria.Operator.ge); lst.add(TableCriteria.Operator.is_null); lst.add(TableCriteria.Operator.is_not_null); return lst; } @Override protected C getValue() { return (C) searchInputControl.getText(); } }; } C defaultSearch = getDefaultSearchValue(); if (defaultSearch != null) { searchInputControl.setText(stringConverter.toString(defaultSearch)); } return searchMenuItem; }
From source file:de.rkl.tools.tzconv.TimezoneConverter.java
private Node createTemplateNameField() { final TextField templateNameField = new TextField(); templateNameField.setEditable(false); final File templateFile = applicationModel.templateFile.getValue(); templateNameField.setText(templateFile == null ? StringUtils.EMPTY : templateFile.getName()); applicationModel.templateFile.addListener((observable, oldValue, newValue) -> { templateNameField.setText(newValue == null ? StringUtils.EMPTY : newValue.getName()); });/*from w ww .ja va 2s . c o m*/ return templateNameField; }
From source file:de.ks.idnadrev.information.chart.ChartDataEditor.java
private TextField createCategoryEditor(ChartRow chartRow, int rowNum) { TextField categoryEditor = new TextField(); categoryEditor.textProperty().bindBidirectional(chartRow.getCategory()); categoryEditor.focusedProperty().addListener(getEditorFocusListener(rowNum, categoryEditor)); categoryEditor.textProperty().addListener((p, o, n) -> { categoryEditor.setUserData(true); });/*from w ww. jav a 2 s. c o m*/ BiFunction<Integer, Integer, TextField> nextCategoryField = (row, column) -> { if (categoryEditors.size() > row) { return categoryEditors.get(row); } else { return null; } }; BiConsumer<Integer, Integer> clipBoardHandler = (row, col) -> { String string = Clipboard.getSystemClipboard().getString(); if (StringUtils.containsWhitespace(string)) { List<String> datas = Arrays.asList(StringUtils.split(string, "\n")); int missingRows = (row + datas.size()) - rows.size(); if (missingRows > 0) { for (int i = 0; i < missingRows; i++) { rows.add(new ChartRow()); } } for (int i = row; i < row + datas.size(); i++) { ChartRow currentChartRow = rows.get(i); String data = datas.get(i - row); currentChartRow.setCategory(data); } } }; categoryEditor.setOnKeyReleased(getInputKeyHandler(rowNum, -1, nextCategoryField, clipBoardHandler)); validationRegistry.registerValidator(categoryEditor, (control, value) -> { if (value != null) { Set<String> values = categoryEditors.stream()// .filter(e -> e != categoryEditor)// .map(e -> e.textProperty().getValueSafe())// .filter(v -> !v.isEmpty())// .collect(Collectors.toSet()); if (values.contains(value)) { ValidationMessage message = new ValidationMessage("validation.noDuplicates", control, value); return ValidationResult.fromMessages(message); } } return null; }); categoryEditors.add(categoryEditor); return categoryEditor; }
From source file:poe.trade.assist.SearchPane.java
private void setupFilterTextField() { nameFilterField = new TextField(); nameFilterField.setMinWidth(200);/* ww w . ja va2s . c o m*/ nameFilterField.setPromptText("filter by name"); tagFilterField = new TextField(); tagFilterField.setMinWidth(200); tagFilterField.setPromptText("filter by tags, csv"); showOnlyNew.setSelected(false); tagFilterField.textProperty().addListener((observable, oldValue, newValue) -> { searchTable.getFilteredData().setPredicate(tagPredicate().and(namePredicate())); }); nameFilterField.textProperty().addListener((observable, oldValue, newValue) -> { searchTable.getFilteredData().setPredicate(tagPredicate().and(namePredicate())); }); showOnlyNew.selectedProperty().addListener(new ChangeListener<Boolean>() { public void changed(ObservableValue<? extends Boolean> ov, Boolean old_val, Boolean new_val) { searchTable.getFilteredData().setPredicate(onlyNewPredicate()); } }); }
From source file:cz.lbenda.gui.tableView.FilterMenuItem.java
private FilterMenuItem(VBox panel, FilterableTableView filterableTableView, FilterableTableColumn filterableTableColumn) { super(null, panel); this.filterableTableView = filterableTableView; okCancelBar.setAlignment(Pos.BOTTOM_RIGHT); this.tableColumn = filterableTableColumn; this.getStyleClass().add("listview-menu-item"); SortedList<Item> sortedList = new SortedList<>(filteredList, Item::compareTo); ListView<Item> listView = new ListView<>(); listView.setItems(sortedList);//from ww w. j a v a2 s . c om listView.setCellFactory(CheckBoxListCell.forListView(Item::onProperty)); TextField textField = new TextField(); textField.textProperty().addListener((observable, oldValue, newValue) -> { filteredList.setPredicate(item -> StringUtils.isEmpty(newValue) || !StringUtils.isEmpty(item.getName()) && item.getName().toLowerCase().contains(newValue.toLowerCase())); }); prepareBars(); prepareQuickFilter(); prepareOkCancelBar(); panel.getChildren().add(buttonBar); panel.getChildren().add(textField); panel.getChildren().add(listView); panel.getChildren().add(quickFilter); panel.getChildren().add(okCancelBar); //noinspection unchecked filterableTableView.sortProperty().addListener((observable, oldValue, newValue) -> { if (newValue == null || (newValue != comparatorAsc && newValue != comparatorDsc)) { filterableTableColumn.removeRightIndicator(sortIndicator); sortToggleGroup.selectToggle(null); } else { filterableTableColumn.removeRightIndicator(sortIndicator); filterableTableColumn.addRightIndicator(sortIndicator); if (newValue == comparatorAsc) { sortIndicator.setImage(IconFactory.getInstance().image(this, ICON_SORT_ASC, IconFactory.IconLocation.INDICATOR)); } else { sortIndicator.setImage(IconFactory.getInstance().image(this, ICON_SORT_DSC, IconFactory.IconLocation.INDICATOR)); } } }); }