Example usage for javafx.scene.control TextField setText

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

Introduction

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

Prototype

public final void setText(String value) 

Source Link

Usage

From source file:account.management.controller.POVoucherController.java

public void calculate() {
    int len = this.container.getChildren().size();
    double total_amount = 0;
    for (int i = 0; i < len; i++) {
        HBox row = (HBox) this.container.getChildren().get(i);
        TextField sl_t = (TextField) row.getChildren().get(0);
        TextField qty_t = (TextField) row.getChildren().get(2);
        TextField rate_t = (TextField) row.getChildren().get(3);
        TextField total_t = (TextField) row.getChildren().get(4);
        TextField commision_t = (TextField) row.getChildren().get(5);
        TextField total_commision_t = (TextField) row.getChildren().get(6);
        TextField neat_amount_t = (TextField) row.getChildren().get(7);

        sl_t.setText(String.valueOf(i + 1));

        double qty = qty_t.getText().isEmpty() ? 0 : Double.parseDouble(qty_t.getText());
        double rate = rate_t.getText().isEmpty() ? 0 : Double.parseDouble(rate_t.getText());
        double total = total_t.getText().isEmpty() ? 0 : Double.parseDouble(total_t.getText());
        double commision = commision_t.getText().isEmpty() ? 0 : Double.parseDouble(commision_t.getText());
        double total_commision = total_commision_t.getText().isEmpty() ? 0
                : Double.parseDouble(total_commision_t.getText());
        double neat_amount = neat_amount_t.getText().isEmpty() ? 0
                : Double.parseDouble(neat_amount_t.getText());

        total = qty * rate;//ww w.j  ava  2 s  .  co m
        total_commision = total * commision / 100;
        neat_amount = total - total_commision;

        total_t.setText(String.valueOf(total));
        total_commision_t.setText(String.valueOf(total_commision));
        neat_amount_t.setText(String.valueOf(neat_amount));
        total_amount += neat_amount;
    }

    this.total_price.setText(String.valueOf(total_amount));
}

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

private void clearTextAndDisable(TextField tf) {
    tf.setText("");
    tf.setDisable(true);
}

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

private void setTextAndEnable(TextField tf, String text) {
    tf.setText(text);
    tf.setDisable(false);
}

From source file:hd3gtv.as5kpc.Serverchannel.java

private String makeName(String suffix_label, TextField showname) {
    StringBuilder sb = new StringBuilder();
    Calendar c = Calendar.getInstance();
    if (c.get(Calendar.DAY_OF_MONTH) < 10) {
        sb.append("0");
    }/*from  w w  w  .  j ava2  s.c  o  m*/
    sb.append(c.get(Calendar.DAY_OF_MONTH));
    sb.append("-");
    if (c.get(Calendar.MONTH) + 1 < 10) {
        sb.append("0");
    }
    sb.append(c.get(Calendar.MONTH) + 1);
    sb.append(" ");

    String show_name = showname.getText();
    show_name = PATTERN_Combining_Diacritical_Marks
            .matcher(Normalizer.normalize(showname.getText(), Normalizer.Form.NFD)).replaceAll("").trim()
            .toUpperCase();
    showname.setText(show_name);

    sb.append(show_name);

    if (show_name.endsWith(suffix_label) == false) {
        sb.append(" ");
        sb.append(suffix_label);
    }
    return sb.toString();
}

From source file:com.playonlinux.javafx.mainwindow.console.ConsoleTab.java

public ConsoleTab(CommandLineInterpreterFactory commandLineInterpreterFactory) {
    final VBox content = new VBox();

    commandInterpreter = commandLineInterpreterFactory.createInstance();

    this.setText(translate("Console"));
    this.setContent(content);

    final TextField command = new TextField();
    command.getStyleClass().add("consoleCommandType");
    final TextFlow console = new TextFlow();
    final ScrollPane consolePane = new ScrollPane(console);
    content.getStyleClass().add("rightPane");

    consolePane.getStyleClass().add("console");
    consolePane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    content.getChildren().addAll(consolePane, command);

    command.requestFocus();//from   www .j  a  va 2  s .  com

    command.setOnKeyPressed(event -> {
        if (event.getCode() == KeyCode.ENTER) {
            final String commandToSend = command.getText();
            final int cursorPosition = command.getCaretPosition();
            command.setDisable(true);
            commandHistory.add(new CommandHistory.Item(commandToSend, cursorPosition));
            Text commandText = new Text(nextSymbol + commandToSend + "\n");
            commandText.getStyleClass().add("commandText");
            console.getChildren().add(commandText);
            command.setText("");

            if (commandInterpreter.sendLine(commandToSend, message -> {
                Platform.runLater(() -> {
                    if (!StringUtils.isBlank(message)) {
                        Text resultText = new Text(message);
                        resultText.getStyleClass().add("resultText");
                        console.getChildren().add(resultText);
                    }
                    command.setDisable(false);
                    command.requestFocus();
                    consolePane.setVvalue(consolePane.getVmax());
                });
            })) {
                nextSymbol = NOT_INSIDE_BLOCK;
            } else {
                nextSymbol = INSIDE_BLOCK;
            }
        }
    });

    command.setOnKeyReleased(event -> {
        if (event.getCode() == KeyCode.UP) {
            CommandHistory.Item historyItem = commandHistory.up();
            command.setText(historyItem.getCommand());
            command.positionCaret(historyItem.getCursorPosition());
        } else if (event.getCode() == KeyCode.DOWN) {
            CommandHistory.Item historyItem = commandHistory.down();
            command.setText(historyItem.getCommand());
            command.positionCaret(historyItem.getCursorPosition());
        }
    });

    this.setOnCloseRequest(event -> commandInterpreter.close());
}

From source file:dsfixgui.view.DSFGraphicsPane.java

private void recheckTextInputUnsafe(TextField field) {
    String text = field.getText();
    field.setText("");
    field.appendText(text);/* w  w w. j  a v a 2  s.co  m*/
}

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);/* w  ww.  jav  a 2 s . c om*/
    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:de.dkfz.roddy.client.fxuiclient.RoddyUIController.java

/**
 * Helper method to fill the content of a text field specifically to an input objects type.
 * If this cannot be done, the default value will be used.
 *//*from  ww  w.j  av a  2 s . c  o m*/
private void fillTextFieldWithObjectValue(TextField textField, Object o, String alternative) {
    String text = null;
    if (o != null) {
        if (o instanceof File) {
            text = ((File) o).getAbsolutePath();
        } else {
            text = o.toString();
        }
    } else {
        text = alternative != null ? alternative : "";
    }
    textField.setText(text);
}

From source file:boundary.GraphPane.java

private Node addThresholdSlider(float min, float max) {
    HBox hBox = new HBox();

    hBox.setPadding(new Insets(15, 12, 15, 12));
    hBox.setStyle("-fx-background-color: #66FFFF;");

    Label lblThreshold = new Label("Threshold: ");
    lblThreshold.setPrefSize(100, 20);//w w  w.  j  a  va2  s .  c om

    Label lblValue = new Label("Value: ");
    lblValue.setPrefSize(50, 20);
    TextField tfValue = new TextField(String.valueOf(min));

    Slider thresholdSlider = new Slider();
    thresholdSlider.setMin(Math.floor(min));
    thresholdSlider.setMax(Math.ceil(max));
    thresholdSlider.setMajorTickUnit(Math.ceil((max - min) / 5));
    thresholdSlider.setMinorTickCount(1);
    thresholdSlider.setBlockIncrement(1);
    thresholdSlider.setSnapToTicks(true);
    thresholdSlider.setShowTickMarks(true);

    thresholdSlider.valueProperty().addListener(new ChangeListener<Number>() {

        @Override
        public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {

            edgePredicate.setThreshold(newValue.floatValue());
            vertexPredicate.setThreshold(newValue.floatValue());

            vv.repaint();

            tfValue.setText(String.format(Locale.US, "%.2f", newValue.floatValue()));

        }
    });

    tfValue.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {

        @Override
        public void handle(KeyEvent event) {
            float value;

            try {
                value = Float.parseFloat(tfValue.getText());
            } catch (Exception ex) {
                value = 0;
            }
            edgePredicate.setThreshold(value);
            vertexPredicate.setThreshold(value);

            vv.repaint();

            thresholdSlider.setValue(value);

        }
    });

    Label lblSearch = new Label("Search: ");
    lblSearch.setPrefSize(70, 20);

    TextField tf = new TextField();

    tf.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {

        @Override
        public void handle(KeyEvent event) {
            String toFind = tf.getText().toLowerCase();

            for (NodeInfo nodeInfo : nodesHighlighted)
                nodeInfo.setHighlighted(false);

            if (nodesHighlighted.size() > 0) {
                nodesHighlighted.clear();
                vv.repaint();
            }

            if (toFind.length() > 2) {
                for (NodeInfo nodeInfo : nodes.values()) {
                    if (nodeInfo.getUserData().toLowerCase().contains((toFind))) {
                        nodeInfo.setHighlighted(true);
                        nodesHighlighted.add(nodeInfo);
                    }
                }

                if (nodesHighlighted.size() == 1) {
                    Layout<String, String> layout = vv.getGraphLayout();
                    Point2D q = layout.transform(nodesHighlighted.get(0).id);
                    Point2D lvc = vv.getRenderContext().getMultiLayerTransformer()
                            .inverseTransform(vv.getCenter());
                    final double dx = (lvc.getX() - q.getX()) / 10;
                    final double dy = (lvc.getY() - q.getY()) / 10;

                    Runnable animator = new Runnable() {

                        public void run() {
                            for (int i = 0; i < 10; i++) {
                                vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT)
                                        .translate(dx, dy);
                                try {
                                    Thread.sleep(100);
                                } catch (InterruptedException ex) {
                                }
                            }
                        }
                    };

                    Thread thread = new Thread(animator);
                    thread.start();
                }
                vv.repaint();
            }
        }
    });

    hBox.getChildren().addAll(lblThreshold, thresholdSlider, lblValue, tfValue, lblSearch, tf);

    return hBox;
}

From source file:hd3gtv.as5kpc.Serverchannel.java

void appCue(TextField mediaid, Label takenum, TextField showname, Button btncue, Button btnrec) {
    int id;/*from w w w .java2 s . co m*/
    int take;
    try {
        id = Integer.parseInt(mediaid.getText());
        take = Integer.valueOf(takenum.getText());
    } catch (Exception e) {
        Alert alert = new Alert(AlertType.WARNING);
        alert.setTitle("Media ID");
        alert.setHeaderText("Erreur lors de la rcupration de l'ID, seuls des chiffres sont autoriss.");
        alert.setContentText("Dtail: " + e.getMessage());
        alert.showAndWait();
        return;
    }

    GetFreeClipIdBackgound gfip = getFreeClipIdBackgound(id + getVtrIndex(), take);

    gfip.setOnSucceeded((WorkerStateEvent ev) -> {
        takenum.setText(gfip.getValue().get("take"));
        String first_name = gfip.getValue().get("first_name");
        if (first_name != null) {
            final String _first_name = first_name.substring("00-00 ".length());
            showname.setText(_first_name);
            if (_first_name.endsWith(getServerLabel())) {
                showname.setText(
                        _first_name.substring(0, _first_name.length() - getServerLabel().length()).trim());
            }
        }

        btncue.setDisable(false);
        mediaid.setDisable(false);
        showname.setDisable(false);
        btnrec.setDisable(false);
    });

    gfip.setOnFailed((WorkerStateEvent ev) -> {
        Alert alert = new Alert(AlertType.WARNING);
        alert.setTitle("Cue");
        alert.setHeaderText("Impossible de rcuperer un tat");
        alert.setContentText("La rcupration du statut de l'Id " + id + " n'a pas fonctionn.");
        alert.showAndWait();

        mediaid.setDisable(false);
        showname.setDisable(false);
    });

    gfip.start();

}