Example usage for javafx.scene.control TextField setPrefHeight

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

Introduction

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

Prototype

public final void setPrefHeight(double value) 

Source Link

Usage

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 w w w  .j  a  v a  2  s.com
    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;
    }

}