Example usage for javafx.scene.control TextField textProperty

List of usage examples for javafx.scene.control TextField textProperty

Introduction

In this page you can find the example usage for javafx.scene.control TextField textProperty.

Prototype

public final StringProperty textProperty() 

Source Link

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    final Stage stageRef = stage;
    Group rootGroup;/*from  w  ww .  j  av  a  2 s . co  m*/
    TextField titleTextField;
    Scene scene = SceneBuilder
            .create().width(270).height(370).root(
                    rootGroup = GroupBuilder.create()
                            .children(HBoxBuilder.create().spacing(10)
                                    .children(new Label("title:"), titleTextField = TextFieldBuilder.create()
                                            .text("Stage Coach").prefColumnCount(15).build())
                                    .build())
                            .build())
            .build();
    title.bind(titleTextField.textProperty());

    stage.setScene(scene);
    stage.titleProperty().bind(title);

    stage.show();
}

From source file:com.github.drbookings.ui.controller.BookingDetailsController.java

private void addRowFees(final Pane content, final BookingBean be) {
    final HBox box = new HBox();

    // configure box
    box.setSpacing(8);/*from  w  ww  . j  ava  2  s .c  om*/
    box.setPadding(boxPadding);
    box.setAlignment(Pos.CENTER);
    box.setFillHeight(true);

    // add cleaning fees
    final TextField cleaningFeesTextField = new TextField();
    Bindings.bindBidirectional(cleaningFeesTextField.textProperty(), be.cleaningFeesProperty(),
            new NumberStringConverter(decimalFormat));
    cleaningFeesTextField.setPrefWidth(prefTextInputFieldWidth);
    final TextFlow cleaningFeesTextFlow = new TextFlow(new Text("Cleaning Fees: "), cleaningFeesTextField,
            new Text(" "));
    box.getChildren().add(cleaningFeesTextFlow);

    // add cleaning costs

    final CleaningEntry ce = be.getCleaning();
    if (ce != null) {
        final TextField cleaningCostsTextField = new TextField();
        Bindings.bindBidirectional(cleaningCostsTextField.textProperty(), ce.cleaningCostsProperty(),
                new NumberStringConverter(decimalFormat));
        cleaningCostsTextField.setPrefWidth(prefTextInputFieldWidth);
        final TextFlow cleaningCostsTextFlow = new TextFlow(new Text("Cleaning Costs: "),
                cleaningCostsTextField, new Text(" "));
        box.getChildren().add(cleaningCostsTextFlow);
    } else {
        final TextField cleaningCostsTextField = new TextField("No Cleaning");
        cleaningCostsTextField.setEditable(false);
        cleaningCostsTextField.setPrefWidth(prefTextInputFieldWidth);
        final TextFlow cleaningCostsTextFlow = new TextFlow(new Text("Cleaning Costs: "),
                cleaningCostsTextField);
        cleaningCostsTextField.getStyleClass().add("warning");
        box.getChildren().add(cleaningCostsTextFlow);
    }

    // add service fees
    final TextField serviceFeesTextField = new TextField();
    Bindings.bindBidirectional(serviceFeesTextField.textProperty(), be.serviceFeeProperty(),
            new NumberStringConverter(decimalFormat));
    serviceFeesTextField.setPrefWidth(prefTextInputFieldWidth);
    final TextFlow serviceFeesAbsTextFlow = new TextFlow(new Text("Service Fees: "), serviceFeesTextField,
            new Text(" "));
    box.getChildren().add(serviceFeesAbsTextFlow);

    // add service fees percent
    final TextField serviceFeesPercentTextField = new TextField();
    Bindings.bindBidirectional(serviceFeesPercentTextField.textProperty(), be.serviceFeesPercentProperty(),
            new NumberStringConverter(decimalFormat));
    serviceFeesPercentTextField.setPrefWidth(prefTextInputFieldWidth);
    final TextFlow serviceFeesPercentTextFlow = new TextFlow(new Text("Service Fees: "),
            serviceFeesPercentTextField, new Text(" %"));

    box.getChildren().add(serviceFeesPercentTextFlow);

    // add box to parent
    content.getChildren().add(box);

}

From source file:com.rcs.shoe.shop.fx.controller.ui.NewProductController.java

private List<ProductHistory> getProductQuantity() {
    List<ProductHistory> result = new ArrayList<>();
    for (TextField tx : quantityFields.values()) {
        Label label = quantityLabels.get(tx.getId().replaceFirst("text", "label"));
        Integer oldValue = new Integer(label.textProperty().getValue().trim());
        Integer newValue = new Integer(tx.textProperty().getValue().trim());

        if (oldValue > newValue) {
            ProductHistory quantityHistory = new ProductHistory();
            quantityHistory.setProductNum(Integer.parseInt(produstNumber.getText()));
            if (storedProduct != null) {
                quantityHistory.setProductCode(storedProduct.getProductCode());
            } else {
                quantityHistory.setProductCode(productCode.getText());
            }//  w w w  .j  a va 2 s  .  c o  m
            quantityHistory.setSize(getSize(tx));
            quantityHistory.setType(2);
            quantityHistory.setQuantity(newValue - oldValue);
            result.add(quantityHistory);
        } else if (oldValue < newValue) {
            ProductHistory quantityHistory = new ProductHistory();
            quantityHistory.setProductCode(productCode.getText());
            quantityHistory.setProductNum(Integer.parseInt(produstNumber.getText()));
            if (storedProduct != null) {
                quantityHistory.setProductCode(storedProduct.getProductCode());
            } else {
                quantityHistory.setProductCode(productCode.getText());
            }
            quantityHistory.setSize(getSize(tx));
            quantityHistory.setType(1);
            quantityHistory.setQuantity(newValue - oldValue);
            result.add(quantityHistory);
        }
    }

    return result;
}

From source file:de.pixida.logtest.designer.automaton.AutomatonEdge.java

private void createDurationInput(final GridPane gp, final boolean isMin,
        final TimeIntervalForEditing timeInterval) {
    final DurationForEditing duration = isMin ? timeInterval.getMinDuration() : timeInterval.getMaxDuration();

    final int targetRow = isMin ? 0 : 1;
    int column = 0;

    final Text fromOrTo = new Text((isMin ? "Min" : "Max") + ": ");
    gp.add(fromOrTo, column++, targetRow);

    final String mathOperator = isMin ? ">" : "<";
    final String inclusive = "Inclusive: " + mathOperator + "=";
    final String exclusive = "Exclusive: " + mathOperator;
    final ChoiceBox<String> intervalBorderInput = new ChoiceBox<>(
            FXCollections.observableArrayList(inclusive, exclusive));
    intervalBorderInput.setValue(duration.isInclusive() ? inclusive : exclusive);
    intervalBorderInput.getSelectionModel().selectedIndexProperty()
            .addListener((ChangeListener<Number>) (observable, oldValue, newValue) -> {
                duration.setInclusive(0 == (Integer) newValue);
                this.timingConditionsUpdated();
                this.getGraph().handleChange();
            });//from  w ww . ja v a2s  . co m
    gp.add(intervalBorderInput, column++, targetRow);

    final TextField valueInput = new TextField(duration.getValue());
    valueInput.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
        duration.setValue(newValue);
        this.timingConditionsUpdated();
        this.getGraph().handleChange();
    });
    gp.add(valueInput, column++, targetRow);

    final String currentChoice = JsonTimeUnit.convertTimeUnitToString(duration.getUnit());
    final ChoiceBox<String> timeUnitInput = new ChoiceBox<>(
            FXCollections.observableArrayList(JsonTimeUnit.getListOfPossibleNames()));
    timeUnitInput.setValue(currentChoice);
    timeUnitInput.getSelectionModel().selectedIndexProperty()
            .addListener((ChangeListener<Number>) (observable, oldValue, newValue) -> {
                duration.setUnit(JsonTimeUnit.indexToTimeUnit((Integer) newValue));
                this.timingConditionsUpdated();
                this.getGraph().handleChange();
            });
    gp.add(timeUnitInput, column++, targetRow);
}

From source file:de.pixida.logtest.designer.automaton.AutomatonEdge.java

protected void createTextFieldInput(final ConfigFrame cf, final String propertyName, final String initialValue,
        final Consumer<String> applyValue, final Monospace monospace) {
    final TextField inputField = new TextField(initialValue);
    this.setMonospaceIfDesired(monospace, inputField);
    inputField.textProperty().addListener((ChangeListener<String>) (observable, oldValue, newValue) -> {
        applyValue.accept(newValue);//www .  ja va  2 s  .  c  o m
        this.getGraph().handleChange();
    });
    cf.addOption(propertyName, inputField);
}

From source file:de.ks.idnadrev.information.chart.ChartDataEditor.java

protected TextField createValueEditor(ChartRow chartRow, int rowNum, int column) {
    TextField editor = new TextField();
    valueEditors.put(rowNum, column, editor);
    validationRegistry.registerValidator(editor, new DoubleValidator());
    dataContainer.add(editor, column + COLUMN_OFFSET, rowNum + ROW_OFFSET);

    editor.focusedProperty().addListener(getEditorFocusListener(rowNum, editor));

    editor.textProperty().addListener((p, o, n) -> {
        editor.setUserData(true);//from  www. j  a v  a2s. com
    });

    BiFunction<Integer, Integer, TextField> nextTextField = (row, col) -> valueEditors.row(row).get(col);
    BiConsumer<Integer, Integer> clipBoardHandler = (row, col) -> {
        String string = Clipboard.getSystemClipboard().getString();
        if (StringUtils.containsWhitespace(string)) {
            List<String> datas = Arrays.asList(StringUtils.split(string));
            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.setValue(column, data);
            }
        }
    };
    editor.setOnKeyReleased(getInputKeyHandler(rowNum, column, nextTextField, clipBoardHandler));
    return editor;
}

From source file:acmi.l2.clientmod.xdat.Controller.java

private Tab createTab(Field listField) {
    Tab tab = new Tab(listField.getName());

    SplitPane pane = new SplitPane();

    TextField filter = TextFields.createClearableTextField();
    VBox.setMargin(filter, new Insets(2));
    TreeView<Object> elements = createTreeView(listField, filter.textProperty());
    VBox.setVgrow(elements, Priority.ALWAYS);
    PropertySheet properties = createPropertySheet(elements);

    pane.getItems().addAll(new VBox(filter, elements), properties);
    pane.setDividerPositions(0.3);// w ww  .  j  a  v  a 2s  . co m

    tab.setContent(wrap(pane));

    return tab;
}

From source file:mesclasses.view.JourneeController.java

/**
 * dessine la grid travail/*w  w w .  j a  va 2 s  .  c  o m*/
 * @param eleve
 * @param rowIndex 
 */
private void drawTravail(Eleve eleve, int rowIndex) {

    EleveData eleveData = seanceSelect.getValue().getDonnees().get(eleve);
    drawEleveName(travailGrid, eleve, rowIndex);
    if (!eleve.isInClasse(currentDate.getValue())) {
        return;
    }
    CheckBox travailBox = new CheckBox();
    Bindings.bindBidirectional(travailBox.selectedProperty(), eleveData.travailPasFaitProperty());
    travailGrid.add(travailBox, 3, rowIndex, null);
    Label cumulTravail = new Label();
    travailBox.selectedProperty().addListener((observable, oldValue, newValue) -> {
        writeAndMarkInRed(cumulTravail, stats.getNbTravailUntil(eleve, currentDate.getValue()), 3);
    });
    writeAndMarkInRed(cumulTravail, stats.getNbTravailUntil(eleve, currentDate.getValue()), 3);
    travailGrid.add(cumulTravail, 4, rowIndex, null);

    CheckBox devoirBox = new CheckBox();
    devoirBox.setSelected(model.getDevoirForSeance(eleve, seanceSelect.getValue()) != null);
    devoirBox.selectedProperty().addListener((ob, o, checked) -> {
        Devoir devoir = model.getDevoirForSeance(eleve, seanceSelect.getValue());
        if (checked && devoir == null) {
            model.createDevoir(eleve, seanceSelect.getValue());
        } else if (devoir != null) {
            model.delete(devoir);
        }
    });
    travailGrid.add(devoirBox, 5, rowIndex, null);

    TextField oubliMaterielField = new TextField();
    Bindings.bindBidirectional(oubliMaterielField.textProperty(), eleveData.oubliMaterielProperty());
    travailGrid.add(oubliMaterielField, 6, rowIndex, HPos.LEFT);
    Label cumulOubli = new Label();
    oubliMaterielField.textProperty().addListener((observable, oldValue, newValue) -> {
        writeAndMarkInRed(cumulOubli, stats.getNbOublisUntil(eleve, currentDate.getValue()), 3);
    });

    writeAndMarkInRed(cumulOubli, stats.getNbOublisUntil(eleve, currentDate.getValue()), 3);
    travailGrid.add(cumulOubli, 7, rowIndex, null);

}

From source file:mesclasses.view.JourneeController.java

/**
 * dessine la grid vie scolaire/*from w w w  .ja v  a 2 s.  c o  m*/
 * @param eleve
 * @param rowIndex 
 */
private void drawVieScolaire(Eleve eleve, int rowIndex) {
    EleveData eleveData = seanceSelect.getValue().getDonnees().get(eleve);
    drawEleveName(vieScolaireGrid, eleve, rowIndex);
    if (!eleve.isInClasse(currentDate.getValue())) {
        return;
    }
    CheckBox box = new CheckBox();
    Bindings.bindBidirectional(box.selectedProperty(), eleveData.absentProperty());
    vieScolaireGrid.add(box, 3, rowIndex, null);

    TextField retardField = new TextField();
    retardField.setMaxWidth(50);
    Bindings.bindBidirectional(retardField.textProperty(), eleveData.retardProperty(),
            new IntegerOnlyConverter());
    markAsInteger(retardField);

    vieScolaireGrid.add(retardField, 4, rowIndex, HPos.CENTER);

    Label cumulRetard = new Label();
    retardField.textProperty().addListener((observable, oldValue, newValue) -> {
        writeAndMarkInRed(cumulRetard, stats.getNbRetardsUntil(eleve, currentDate.getValue()), 3);
    });

    writeAndMarkInRed(cumulRetard, stats.getNbRetardsUntil(eleve, currentDate.getValue()), 3);
    vieScolaireGrid.add(cumulRetard, 5, rowIndex, null);
}

From source file:tachyon.view.ProjectProperties.java

public ProjectProperties(JavaProject project, Window w) {
    this.project = project;
    stage = new Stage();
    stage.initOwner(w);//from w  ww . ja v a  2s .c o m
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.setWidth(600);
    stage.setTitle("Project Properties - " + project.getProjectName());
    stage.getIcons().add(tachyon.Tachyon.icon);
    stage.setResizable(false);
    HBox mai, libs, one, two, thr, fou;
    ListView<String> compileList, runtimeList;
    Button compileAdd, compileRemove, preview, selectIm, runtimeAdd, runtimeRemove;
    TextField iconField;
    stage.setScene(new Scene(new VBox(5, pane = new TabPane(
            new Tab("Library Settings",
                    box1 = new VBox(15,
                            libs = new HBox(10, new Label("External Libraries"), libsView = new ListView<>(),
                                    new VBox(5, addJar = new Button("Add Jar"),
                                            removeJar = new Button("Remove Jar"))))),
            new Tab("Program Settings",
                    new ScrollPane(box2 = new VBox(15, one = new HBox(10, new Label("Main-Class"),
                            mainClass = new TextField(project.getMainClassName()),
                            select = new Button("Select")),
                            two = new HBox(10, new Label("Compile-Time Arguments"),
                                    compileList = new ListView<>(),
                                    new VBox(5, compileAdd = new Button("Add Argument"),
                                            compileRemove = new Button("Remove Argument")))))),
            new Tab("Deployment Settings",
                    box3 = new VBox(15, thr = new HBox(10, new Label("Icon File"),
                            iconField = new TextField(project.getFileIconPath()),
                            preview = new Button("Preview Image"), selectIm = new Button("Select Icon")),
                            fou = new HBox(10, new Label("Runtime Arguments"), runtimeList = new ListView<>(),
                                    new VBox(5, runtimeAdd = new Button("Add Argument"),
                                            runtimeRemove = new Button("Remove Argument")))))),
            new VBox(15, mai = new HBox(10, cancel = new Button("Cancel"), confirm = new Button("Confirm"))))));
    if (applyCss.get()) {
        stage.getScene().getStylesheets().add(css);
    }
    for (Tab b : pane.getTabs()) {
        b.setClosable(false);
    }
    mainClass.setPromptText("Main-Class");
    box1.setPadding(new Insets(5, 10, 5, 10));
    mai.setAlignment(Pos.CENTER_RIGHT);
    mai.setPadding(box1.getPadding());
    libs.setAlignment(Pos.CENTER);
    one.setAlignment(Pos.CENTER);
    two.setAlignment(Pos.CENTER);
    thr.setAlignment(Pos.CENTER);
    fou.setAlignment(Pos.CENTER);
    box1.setAlignment(Pos.CENTER);
    box2.setPadding(box1.getPadding());
    box2.setAlignment(Pos.CENTER);
    box3.setPadding(box1.getPadding());
    box3.setAlignment(Pos.CENTER);
    mainClass.setEditable(false);
    mainClass.setPrefWidth(200);
    for (JavaLibrary lib : project.getAllLibs()) {
        libsView.getItems().add(lib.getBinaryAbsolutePath());
    }
    for (String sa : project.getCompileTimeArguments().keySet()) {
        compileList.getItems().add(sa + ":" + project.getCompileTimeArguments().get(sa));
    }
    for (String sa : project.getRuntimeArguments()) {
        runtimeList.getItems().add(sa);
    }
    compileAdd.setOnAction((e) -> {
        Dialog<Pair<String, String>> dialog = new Dialog<>();
        dialog.setTitle("Compiler Argument");
        dialog.initOwner(stage);
        dialog.setHeaderText("Entry the argument");

        ButtonType loginButtonType = new ButtonType("Done", ButtonData.OK_DONE);
        dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL);

        GridPane grid = new GridPane();
        grid.setHgap(10);
        grid.setVgap(10);
        grid.setPadding(new Insets(20, 150, 10, 10));

        TextField username = new TextField();
        username.setPromptText("Key");
        TextField password = new TextField();
        password.setPromptText("Value");

        grid.add(new Label("Key:"), 0, 0);
        grid.add(username, 1, 0);
        grid.add(new Label("Value:"), 0, 1);
        grid.add(password, 1, 1);

        Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType);
        loginButton.setDisable(true);

        username.textProperty().addListener((observable, oldValue, newValue) -> {
            loginButton.setDisable(newValue.trim().isEmpty());
        });

        dialog.getDialogPane().setContent(grid);

        Platform.runLater(() -> username.requestFocus());

        dialog.setResultConverter(dialogButton -> {
            if (dialogButton == loginButtonType) {
                return new Pair<>(username.getText(), password.getText());
            }
            return null;
        });

        Optional<Pair<String, String>> result = dialog.showAndWait();
        if (result.isPresent()) {
            compileList.getItems().add(result.get().getKey() + ":" + result.get().getValue());
        }
    });
    compileRemove.setOnAction((e) -> {
        if (compileList.getSelectionModel().getSelectedItem() != null) {
            compileList.getItems().remove(compileList.getSelectionModel().getSelectedItem());
        }
    });
    runtimeAdd.setOnAction((e) -> {
        TextInputDialog dia = new TextInputDialog();
        dia.setTitle("Add Runtime Argument");
        dia.setHeaderText("Enter an argument");
        dia.initOwner(stage);
        Optional<String> res = dia.showAndWait();
        if (res.isPresent()) {
            runtimeList.getItems().add(res.get());
        }
    });
    runtimeRemove.setOnAction((e) -> {
        if (runtimeList.getSelectionModel().getSelectedItem() != null) {
            runtimeList.getItems().remove(runtimeList.getSelectionModel().getSelectedItem());
        }
    });
    preview.setOnAction((e) -> {
        if (!iconField.getText().isEmpty()) {
            if (iconField.getText().endsWith(".ico")) {
                List<BufferedImage> read = new ArrayList<>();
                try {
                    read.addAll(ICODecoder.read(new File(iconField.getText())));
                } catch (IOException ex) {
                }
                if (read.size() >= 1) {
                    Image im = SwingFXUtils.toFXImage(read.get(0), null);
                    Stage st = new Stage();
                    st.initOwner(stage);
                    st.initModality(Modality.APPLICATION_MODAL);
                    st.setTitle("Icon Preview");
                    st.getIcons().add(Tachyon.icon);
                    st.setScene(new Scene(new BorderPane(new ImageView(im))));
                    if (applyCss.get()) {
                        st.getScene().getStylesheets().add(css);
                    }
                    st.showAndWait();
                }
            } else if (iconField.getText().endsWith(".icns")) {
                try {
                    BufferedImage ima = Imaging.getBufferedImage(new File(iconField.getText()));
                    if (ima != null) {
                        Image im = SwingFXUtils.toFXImage(ima, null);
                        Stage st = new Stage();
                        st.initOwner(stage);
                        st.initModality(Modality.APPLICATION_MODAL);
                        st.setTitle("Icon Preview");
                        st.getIcons().add(Tachyon.icon);
                        st.setScene(new Scene(new BorderPane(new ImageView(im))));
                        if (applyCss.get()) {
                            st.getScene().getStylesheets().add(css);
                        }
                        st.showAndWait();
                    }
                } catch (ImageReadException | IOException ex) {
                }
            } else {
                Image im = new Image(new File(iconField.getText()).toURI().toString());
                Stage st = new Stage();
                st.initOwner(stage);
                st.initModality(Modality.APPLICATION_MODAL);
                st.setTitle("Icon Preview");
                st.getIcons().add(Tachyon.icon);
                st.setScene(new Scene(new BorderPane(new ImageView(im))));
                if (applyCss.get()) {
                    st.getScene().getStylesheets().add(css);
                }
                st.showAndWait();
            }
        }
    });
    selectIm.setOnAction((e) -> {
        FileChooser fc = new FileChooser();
        fc.setTitle("Icon File");
        String OS = System.getProperty("os.name").toLowerCase();
        fc.getExtensionFilters().add(new ExtensionFilter("Icon File",
                OS.contains("win") ? getWindowsImageExtensions() : getMacImageExtensions()));
        fc.setSelectedExtensionFilter(fc.getExtensionFilters().get(0));
        File lf = fc.showOpenDialog(stage);
        if (lf != null) {
            iconField.setText(lf.getAbsolutePath());
        }
    });

    addJar.setOnAction((e) -> {
        FileChooser f = new FileChooser();
        f.setTitle("External Libraries");
        f.setSelectedExtensionFilter(new ExtensionFilter("Jar Files", "*.jar"));
        List<File> showOpenMultipleDialog = f.showOpenMultipleDialog(stage);
        if (showOpenMultipleDialog != null) {
            for (File fi : showOpenMultipleDialog) {
                if (!libsView.getItems().contains(fi.getAbsolutePath())) {
                    libsView.getItems().add(fi.getAbsolutePath());
                }
            }
        }
    });

    removeJar.setOnAction((e) -> {
        String selected = libsView.getSelectionModel().getSelectedItem();
        if (selected != null) {
            libsView.getItems().remove(selected);
        }
    });

    select.setOnAction((e) -> {
        List<String> all = getAll();
        ChoiceDialog<String> di = new ChoiceDialog<>(project.getMainClassName(), all);
        di.setTitle("Select Main Class");
        di.initOwner(stage);
        di.setHeaderText("Select A Main Class");
        Optional<String> show = di.showAndWait();
        if (show.isPresent()) {
            mainClass.setText(show.get());
        }
    });
    cancel.setOnAction((e) -> {
        stage.close();
    });
    confirm.setOnAction((e) -> {
        project.setMainClassName(mainClass.getText());
        project.setFileIconPath(iconField.getText());
        project.setRuntimeArguments(runtimeList.getItems());
        HashMap<String, String> al = new HashMap<>();
        for (String s : compileList.getItems()) {
            String[] spl = s.split(":");
            al.put(spl[0], spl[1]);
        }
        project.setCompileTimeArguments(al);
        project.setAllLibs(libsView.getItems());
        stage.close();
    });
}