Example usage for javafx.scene.control TextField setPrefWidth

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

Introduction

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

Prototype

public final void setPrefWidth(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 .  co 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:account.management.controller.expenseVoucherController.java

@FXML
private void onAddNewButtonClick(ActionEvent event) {

    HBox row = new HBox();
    TextField desc = new TextField();
    TextField amount = new TextField();
    Button delete = new Button("Delete");
    desc.setPrefWidth(this.desc.getPrefWidth());
    amount.setPrefWidth(this.amount.getPrefWidth());
    row.getChildren().addAll(desc, amount, delete);
    row.setSpacing(this.row.getSpacing());
    this.container.getChildren().add(row);
    calculateTotal();//  w ww . ja v  a 2s  . c  om
    delete.setOnAction((e) -> {
        this.container.getChildren().remove(row);
        this.add_new.setDisable(false);
        calculateTotal();
    });
    amount.setOnKeyReleased((e) -> {
        calculateTotal();
    });
    if (this.container.getChildren().size() >= 5) {
        this.add_new.setDisable(true);
        return;
    }
}

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

public void addNewRow() {
    TextField sl = new TextField();
    sl.setPromptText("SL");
    sl.setPrefWidth(54);
    sl.setEditable(false);/*from  www  .  j a  v a 2 s.c o  m*/

    TextField desc = new TextField();
    desc.setPromptText("Description");
    desc.setPrefWidth(216);

    TextField qty = new TextField();
    qty.setPromptText("Quantity");
    qty.setPrefWidth(62);
    qty.setOnKeyReleased((e) -> {
        calculate();
    });

    TextField rate = new TextField();
    rate.setPromptText("Rate");
    rate.setPrefWidth(72);
    rate.setOnKeyReleased((e) -> {
        calculate();
    });

    TextField total = new TextField();
    total.setPromptText("Total");
    total.setPrefWidth(80);
    total.setEditable(false);

    TextField commision = new TextField();
    commision.setPromptText("Commision %");
    commision.setPrefWidth(90);
    commision.setOnKeyReleased((e) -> {
        calculate();
    });

    TextField total_commision = new TextField();
    total_commision.setPromptText("Total Commision");
    total_commision.setPrefWidth(132);
    total_commision.setEditable(false);

    TextField neat_total = new TextField();
    neat_total.setPromptText("Neat Amount");
    neat_total.setPrefWidth(115);
    neat_total.setEditable(false);

    Button delete = new Button("Delete");

    HBox row = new HBox();
    row.setSpacing(10);
    row.getChildren().addAll(sl, desc, qty, rate, total, commision, total_commision, neat_total, delete);

    delete.setOnAction((e) -> {
        this.container.getChildren().remove(row);
        calculate();
    });

    this.container.getChildren().add(row);
    calculate();

}

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);//from w  ww  .j  a  v  a  2  s. 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: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.  ja  va2  s  .  com
    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:account.management.controller.NewVoucherController.java

@FXML
private void onAddNewFieldButtonClick(ActionEvent event) {

    HBox row = new HBox();
    row.setId("field_row");
    ComboBox<Account> select_account = new ComboBox<>();
    if (this.select_type.getSelectionModel().isEmpty()) {
        select_account.getItems().addAll(this.account_list);
    } else {/*from w  ww . j  a va  2s .  c om*/
        select_account.getItems().addAll(this.filter_acc);
    }

    TextField dr = new TextField();
    TextField cr = new TextField();
    TextField remarks = new TextField();
    Button del_row = new Button("Delete");

    row.setSpacing(field_row.getSpacing());

    ComboBox<Account> combo = (ComboBox) field_row.getChildren().get(0);
    select_account.setPrefWidth(combo.getPrefWidth());
    select_account.setPromptText("Select account");

    TextField tf = (TextField) field_row.getChildren().get(1);
    dr.setPrefWidth(tf.getPrefWidth());
    dr.setPromptText("Dr");

    tf = (TextField) field_row.getChildren().get(2);
    cr.setPrefWidth(tf.getPrefWidth());
    cr.setPromptText("Cr");

    tf = (TextField) field_row.getChildren().get(3);
    remarks.setPrefWidth(tf.getPrefWidth());
    remarks.setPromptText("remarks");

    row.getChildren().addAll(select_account, dr, cr, remarks, del_row);
    field_container.getChildren().add(row);

    del_row.setOnMouseClicked((MouseEvent event1) -> {
        field_container.getChildren().removeAll(row);
        validateFields();
    });

    combo.setOnAction((e) -> {
        if (!combo.getSelectionModel().isEmpty() && combo.getSelectionModel().getSelectedItem().getId() == 21) {
            combo.setPromptText("Select Party");
            combo.getItems().clear();
            combo.getItems().addAll(this.filter_party_rec);
        }
        if (!combo.getSelectionModel().isEmpty() && combo.getSelectionModel().getSelectedItem().getId() == 34) {
            combo.getItems().clear();
            combo.getItems().addAll(this.filter_party_pay);
            combo.setPromptText("Select Party");
        }
    });

    new AutoCompleteComboBoxListener<>(select_account);
    select_account.setOnHiding((e) -> {
        Account a = select_account.getSelectionModel().getSelectedItem();
        select_account.setEditable(false);
        select_account.getSelectionModel().select(a);
    });
    select_account.setOnShowing((e) -> {
        select_account.setEditable(true);
    });

    validateFields();

}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param strNomFichierBarre/*from   w  w w.j  a v a  2 s .c  om*/
 */
public static void creerEditerBarre(String strNomFichierBarre) {
    apCreationBarre.getChildren().clear();
    apCreationBarre.setStyle("-fx-background-color : -fx-base;" + "-fx-border-color: derive(-fx-base,10%);"
            + "-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.5) , 8, 0.0 , 0 , 8 );"
            + "-fx-border-width: 1px;");

    AnchorPane apOutilsBarre = new AnchorPane();
    Button btnAnnulerBarre = new Button(rbLocalisation.getString("main.quitter"),
            new ImageView(new Image("file:" + getStrRepertAppli() + "/images/annule.png")));
    final Button btnSauverBarre = new Button(rbLocalisation.getString("main.sauver"), new ImageView(
            new Image("file:" + getStrRepertAppli() + "/images/sauveProjet.png", 24, 24, true, true, true)));
    Rectangle2D tailleEcran = Screen.getPrimary().getBounds();
    btnAjouteZone = new Button(rbLocalisation.getString("main.ajouteZone"), new ImageView(
            new Image("file:" + getStrRepertAppli() + "/images/btn+.png", 24, 24, true, true, true)));
    apImgBarrePersonnalisee = new AnchorPane();
    apImgBarrePersonnalisee.getChildren().clear();
    apZoneBarrePersonnalisee = new AnchorPane();
    apZoneBarrePersonnalisee.getChildren().clear();
    apZoneBarrePersonnalisee.setLayoutX(0);
    apZoneBarrePersonnalisee.setLayoutY(150);
    apZoneBarrePersonnalisee.setPrefWidth(300);
    apZoneBarrePersonnalisee.setPrefHeight(200);

    int iLargeurEcran = (int) tailleEcran.getWidth();
    int iHauteurEcran = (int) tailleEcran.getHeight() - 100;
    final int iLargeur = 1200;
    final int iHauteur = 600;
    mbarPrincipal.setDisable(true);
    bbarPrincipal.setDisable(true);
    hbBarreBouton.setDisable(true);
    tpEnvironnement.setDisable(true);
    apCreationBarre.setPrefWidth(iLargeur);
    apCreationBarre.setMinWidth(iLargeur);
    apCreationBarre.setMaxWidth(iLargeur);
    apCreationBarre.setPrefHeight(iHauteur);
    apCreationBarre.setMinHeight(iHauteur);
    apCreationBarre.setMaxHeight(iHauteur);
    apCreationBarre.setLayoutX((iLargeurEcran - iLargeur) / 2);
    apCreationBarre.setLayoutY((iHauteurEcran - iHauteur) / 2);
    apCreationBarre.setVisible(true);
    Label lblBarrePersonnalisee = new Label(rbLocalisation.getString("main.creeBarrePersonnalisee"));
    lblBarrePersonnalisee.setMinWidth(iLargeur - 10);
    lblBarrePersonnalisee.setAlignment(Pos.CENTER);
    lblBarrePersonnalisee.setStyle("-fx-background-color : #777;");
    lblBarrePersonnalisee.setTextFill(Color.WHITE);
    lblBarrePersonnalisee.setLayoutX(5);
    lblBarrePersonnalisee.setLayoutY(10);
    lblBarrePersonnalisee.setFont(Font.font(14));
    apCreationBarre.getChildren().add(lblBarrePersonnalisee);
    apOutilsBarre.setPrefWidth(300);
    apOutilsBarre.setMinWidth(300);
    apOutilsBarre.setMaxWidth(300);
    apOutilsBarre.setPrefHeight(iHauteur - 50);
    apOutilsBarre.setMinHeight(iHauteur - 50);
    apOutilsBarre.setMaxHeight(iHauteur - 50);
    apOutilsBarre.setLayoutX(iLargeur - 302);
    apOutilsBarre.setLayoutY(50);

    apOutilsBarre.setStyle(
            "-fx-background-color : -fx-background;-fx-border-width : 1px;-fx-border-color : transparent transparent transparent -fx-outer-border;");
    btnAnnulerBarre.setPrefWidth(120);
    btnAnnulerBarre.setLayoutX(30);
    btnAnnulerBarre.setLayoutY(iHauteur - 90);
    btnSauverBarre.setPrefWidth(120);
    btnSauverBarre.setLayoutX(160);
    btnSauverBarre.setLayoutY(iHauteur - 90);
    btnSauverBarre.setDisable(true);
    Label lblChargeImage = new Label(rbLocalisation.getString("main.chargeImage"));
    lblChargeImage.setLayoutX(20);
    lblChargeImage.setLayoutY(10);
    TextField tfChargeImage = new TextField("");
    tfChargeImage.setDisable(true);
    tfChargeImage.setPrefWidth(200);
    tfChargeImage.setLayoutX(50);
    tfChargeImage.setLayoutY(40);
    Button btnChargeImage = new Button("...");
    btnChargeImage.setLayoutX(260);
    btnChargeImage.setLayoutY(40);
    final CheckBox cbMasqueZones = new CheckBox(rbLocalisation.getString("main.masqueZones"));
    cbMasqueZones.setDisable(true);
    cbMasqueZones.setLayoutX(20);
    cbMasqueZones.setLayoutY(70);
    btnAjouteZone.setLayoutX(130);
    btnAjouteZone.setLayoutY(110);
    btnAjouteZone.setDisable(true);
    apOutilsBarre.getChildren().addAll(lblChargeImage, tfChargeImage, btnChargeImage, cbMasqueZones,
            btnAjouteZone, apZoneBarrePersonnalisee, btnAnnulerBarre, btnSauverBarre);

    apCreationBarre.getChildren().addAll(apImgBarrePersonnalisee, apOutilsBarre);
    if (!strNomFichierBarre.equals("")) {
        lblChargeImage.setVisible(false);
        tfChargeImage.setVisible(false);
        btnChargeImage.setVisible(false);
        String strNomFichier = strNomFichierBarre;
        strNomFichier = strNomFichier.substring(0, strNomFichier.length() - 4);
        strNomFichierShp = strNomFichier + ".shp";
        String strNomFichierPng = strNomFichier + ".png";
        File fichPng = new File(strNomFichierPng);
        if (fichPng.exists()) {
            try {
                btnAjouteZone.setDisable(false);
                imgBarrePersonnalisee = new Image("file:" + fichPng);
                iNombreZones = getGestionnaireInterface().lisFichierShp(strNomFichierShp, zones);
                btnSauverBarre.setDisable(false);
                if (iNombreZones > 0) {
                    cbMasqueZones.setDisable(false);
                }
                afficheBarrePersonnalisee(iLargeur, iHauteur, false);

            } catch (IOException ex) {
                Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
    }

    btnAnnulerBarre.setOnMouseClicked((t) -> {
        mbarPrincipal.setDisable(false);
        bbarPrincipal.setDisable(false);
        hbBarreBouton.setDisable(false);
        tpEnvironnement.setDisable(false);
        apCreationBarre.setVisible(false);
    });

    btnAjouteZone.setOnMouseClicked((t) -> {
        btnAjouteZone.setDisable(true);
        ajouterZone(iLargeur, iHauteur, false);
    });
    btnChargeImage.setOnMouseClicked((t) -> {
        strRepertBarrePersonnalisee = getStrRepertAppli() + "/theme/telecommandes";
        File fileRepert;
        fileRepert = new File(strRepertBarrePersonnalisee);
        FileChooser fileChooser = new FileChooser();
        FileChooser.ExtensionFilter efShpFilter = new FileChooser.ExtensionFilter(
                "Fichiers barre personnalise (SHP)", "*.shp", "*.png");

        fileChooser.setInitialDirectory(fileRepert);
        fileChooser.getExtensionFilters().addAll(efShpFilter);

        File fileFichierImage = fileChooser.showOpenDialog(null);
        if (fileFichierImage != null) {
            String strNomFichier = fileFichierImage.getAbsolutePath();
            strNomFichier = strNomFichier.substring(0, strNomFichier.length() - 4);
            strNomFichierShp = strNomFichier + ".shp";
            String strNomFichierPng = strNomFichier + ".png";
            File fileFichierPng = new File(strNomFichierPng);
            if (fileFichierPng.exists()) {
                try {
                    btnAjouteZone.setDisable(false);
                    imgBarrePersonnalisee = new Image("file:" + fileFichierPng);
                    iNombreZones = getGestionnaireInterface().lisFichierShp(strNomFichierShp, zones);
                    btnSauverBarre.setDisable(false);
                    if (iNombreZones > 0) {
                        cbMasqueZones.setDisable(false);
                    }
                    afficheBarrePersonnalisee(iLargeur, iHauteur, false);

                } catch (IOException ex) {
                    Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    });

    btnSauverBarre.setOnMouseClicked((t) -> {
        try {
            sauverBarre(strNomFichierShp);
            getGestionnaireInterface().chargeBarrePersonnalisee(strNomFichierBarre);

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    cbMasqueZones.selectedProperty()
            .addListener((ObservableValue<? extends Boolean> ov, Boolean old_val, Boolean new_val) -> {
                afficheBarrePersonnalisee(iLargeur, iHauteur, new_val);
            });

}