Example usage for javafx.scene.layout HBox setSpacing

List of usage examples for javafx.scene.layout HBox setSpacing

Introduction

In this page you can find the example usage for javafx.scene.layout HBox setSpacing.

Prototype

public final void setSpacing(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);//w w w .j ava 2 s .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:Main.java

@Override
public void start(Stage primaryStage) {
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250, Color.WHITE);

    HBox hbox = new HBox();
    Button button1 = new Button("Add");
    Button button2 = new Button("Remove");
    HBox.setHgrow(button1, Priority.ALWAYS);
    HBox.setHgrow(button2, Priority.ALWAYS);
    button1.setMaxWidth(Double.MAX_VALUE);
    button2.setMaxWidth(Double.MAX_VALUE);
    hbox.getChildren().addAll(button1, button2);

    hbox.setPrefWidth(400);//w  w w  .j av a 2 s  .c  om

    hbox.setSpacing(10);

    root.getChildren().add(hbox);
    primaryStage.setScene(scene);
    primaryStage.show();
}

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

public void addNewRow() {
    TextField sl = new TextField();
    sl.setPromptText("SL");
    sl.setPrefWidth(54);/*from  w ww  . jav a 2s.c  om*/
    sl.setEditable(false);

    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:io.bitsquare.gui.components.paymentmethods.SepaForm.java

@Override
public void addFormForAddAccount() {
    gridRowFrom = gridRow + 1;/*www  . j  a  v  a 2 s.c o m*/

    InputTextField holderNameInputTextField = addLabelInputTextField(gridPane, ++gridRow,
            "Account holder name:").second;
    holderNameInputTextField.setValidator(inputValidator);
    holderNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        sepaAccount.setHolderName(newValue);
        updateFromInputs();
    });

    ibanInputTextField = addLabelInputTextField(gridPane, ++gridRow, "IBAN:").second;
    ibanInputTextField.setValidator(ibanValidator);
    ibanInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        sepaAccount.setIban(newValue);
        updateFromInputs();

    });
    bicInputTextField = addLabelInputTextField(gridPane, ++gridRow, "BIC:").second;
    bicInputTextField.setValidator(bicValidator);
    bicInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        sepaAccount.setBic(newValue);
        updateFromInputs();

    });

    addLabel(gridPane, ++gridRow, "Country of bank:");
    HBox hBox = new HBox();
    hBox.setSpacing(10);
    ComboBox<Country> countryComboBox = new ComboBox<>();
    currencyComboBox = new ComboBox<>();
    currencyTextField = new TextField("");
    currencyTextField.setEditable(false);
    currencyTextField.setMouseTransparent(true);
    currencyTextField.setFocusTraversable(false);
    currencyTextField.setMinWidth(300);

    currencyTextField.setVisible(false);
    currencyTextField.setManaged(false);
    currencyComboBox.setVisible(false);
    currencyComboBox.setManaged(false);

    hBox.getChildren().addAll(countryComboBox, currencyTextField, currencyComboBox);
    GridPane.setRowIndex(hBox, gridRow);
    GridPane.setColumnIndex(hBox, 1);
    gridPane.getChildren().add(hBox);

    countryComboBox.setPromptText("Select country of bank");
    countryComboBox.setConverter(new StringConverter<Country>() {
        @Override
        public String toString(Country country) {
            return country.name + " (" + country.code + ")";
        }

        @Override
        public Country fromString(String s) {
            return null;
        }
    });
    countryComboBox.setOnAction(e -> {
        Country selectedItem = countryComboBox.getSelectionModel().getSelectedItem();
        sepaAccount.setCountry(selectedItem);
        TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(selectedItem.code);
        setupCurrency(selectedItem, currency);

        updateCountriesSelection(true, euroCountryCheckBoxes);
        updateCountriesSelection(true, nonEuroCountryCheckBoxes);
        updateFromInputs();
    });

    addEuroCountriesGrid(true);
    addNonEuroCountriesGrid(true);
    addAllowedPeriod();
    addAccountNameTextFieldWithAutoFillCheckBox();

    countryComboBox.setItems(FXCollections.observableArrayList(CountryUtil.getAllSepaCountries()));
    Country country = CountryUtil.getDefaultCountry();
    if (CountryUtil.getAllSepaCountries().contains(country)) {
        countryComboBox.getSelectionModel().select(country);
        sepaAccount.setCountry(country);
        TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(country.code);
        setupCurrency(country, currency);
    }

    updateFromInputs();
}

From source file:de.pixida.logtest.designer.logreader.LogReaderEditor.java

public VBox createRunForm() {
    // CHECKSTYLE:OFF Yes, we are using lots of constants here. It does not make sense to name them using final variables.
    final VBox lines = new VBox();
    lines.setSpacing(10d);/*from  w w w.jav a 2s.  co m*/
    final HBox inputTypeLine = new HBox();
    inputTypeLine.setSpacing(30d);
    final ToggleGroup group = new ToggleGroup();
    final RadioButton inputTypeText = new RadioButton("Paste/Enter text");
    inputTypeText.setToggleGroup(group);
    final RadioButton inputTypeFile = new RadioButton("Read log file");
    inputTypeFile.setToggleGroup(group);
    inputTypeLine.getChildren().add(inputTypeText);
    inputTypeLine.getChildren().add(inputTypeFile);
    inputTypeText.setSelected(true);
    final TextField pathInput = new TextField();
    HBox.setHgrow(pathInput, Priority.ALWAYS);
    final Button selectLogFileButton = SelectFileButton.createButtonWithFileSelection(pathInput,
            LOG_FILE_ICON_NAME, "Select log file", null, null);
    final Text pathInputLabel = new Text("Log file path: ");
    final HBox fileInputConfig = new HBox();
    fileInputConfig.setAlignment(Pos.CENTER_LEFT);
    fileInputConfig.visibleProperty().bind(inputTypeFile.selectedProperty());
    fileInputConfig.managedProperty().bind(fileInputConfig.visibleProperty());
    fileInputConfig.getChildren().addAll(pathInputLabel, pathInput, selectLogFileButton);
    final TextArea logInputText = new TextArea();
    HBox.setHgrow(logInputText, Priority.ALWAYS);
    logInputText.setPrefRowCount(10);
    logInputText.setStyle("-fx-font-family: monospace");
    final HBox enterTextConfig = new HBox();
    enterTextConfig.getChildren().add(logInputText);
    enterTextConfig.visibleProperty().bind(inputTypeText.selectedProperty());
    enterTextConfig.managedProperty().bind(enterTextConfig.visibleProperty());
    final Button startBtn = new Button("Read Log");
    startBtn.setPadding(new Insets(8d));
    // CHECKSTYLE:ON
    startBtn.setGraphic(Icons.getIconGraphics("control_play_blue"));
    HBox.setHgrow(startBtn, Priority.ALWAYS);
    startBtn.setMaxWidth(Double.MAX_VALUE);
    startBtn.setOnAction(event -> this.runLogFileReader(inputTypeFile, pathInput, logInputText));
    final HBox startLine = new HBox();
    startLine.getChildren().add(startBtn);
    lines.getChildren().addAll(inputTypeLine, fileInputConfig, enterTextConfig, startLine, new Text("Results:"),
            this.parsedLogEntries);
    return lines;
}

From source file:fruitproject.FruitProject.java

public void first(final Stage primaryStage) {
    GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);/*  www.  ja va2 s.  com*/
    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.github.drbookings.ui.controller.BookingDetailsController.java

private void addRowNetEarnings(final Pane content, final BookingBean be) {
    final HBox box = new HBox();
    box.setSpacing(boxSpacing);
    box.setPadding(boxPadding);/*from   w w  w .  j  a  va2  s.co  m*/
    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: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();/*from ww w.j av a  2 s .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:de.pixida.logtest.designer.testrun.TestRunEditor.java

public void createLogFileSourceInputItems(final List<Triple<String, Node, String>> formItems) {
    final TextField logFilePath = new TextField();
    this.logFilePathProperty.bind(logFilePath.textProperty());
    HBox.setHgrow(logFilePath, Priority.ALWAYS);
    final Button selectLogFileButton = SelectFileButton.createButtonWithFileSelection(logFilePath,
            LogReaderEditor.LOG_FILE_ICON_NAME, "Select log file", null, null);
    final HBox fileInputConfig = new HBox(logFilePath, selectLogFileButton);
    final VBox lines = new VBox();
    final double spacingOfLines = 5d;
    lines.setSpacing(spacingOfLines);//from ww  w  .j av  a2 s.  c o  m
    final HBox inputTypeLine = new HBox();
    final double hSpacingOfInputTypeChoices = 30d;
    inputTypeLine.setSpacing(hSpacingOfInputTypeChoices);
    final ToggleGroup group = new ToggleGroup();
    final RadioButton inputTypeText = new RadioButton("Paste/Enter log");
    inputTypeText.setToggleGroup(group);
    this.loadLogFromEnteredTextProperty.bind(inputTypeText.selectedProperty());
    final RadioButton inputTypeFile = new RadioButton("Read log file");
    inputTypeFile.setToggleGroup(group);
    this.loadLogFromFileProperty.bind(inputTypeFile.selectedProperty());
    inputTypeFile.setSelected(true);
    inputTypeLine.getChildren().add(inputTypeText);
    inputTypeLine.getChildren().add(inputTypeFile);
    fileInputConfig.visibleProperty().bind(inputTypeFile.selectedProperty());
    fileInputConfig.managedProperty().bind(fileInputConfig.visibleProperty());
    final TextArea logInputText = new TextArea();
    HBox.setHgrow(logInputText, Priority.ALWAYS);
    final int numLinesForEnteringLogInputManually = 10;
    logInputText.setPrefRowCount(numLinesForEnteringLogInputManually);
    logInputText.setStyle("-fx-font-family: monospace");
    this.enteredLogTextProperty.bind(logInputText.textProperty());
    final HBox enterTextConfig = new HBox();
    enterTextConfig.getChildren().add(logInputText);
    enterTextConfig.visibleProperty().bind(inputTypeText.selectedProperty());
    enterTextConfig.managedProperty().bind(enterTextConfig.visibleProperty());
    lines.getChildren().addAll(inputTypeLine, fileInputConfig, enterTextConfig);
    formItems.add(Triple.of("Trace Log", lines, null));
}

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);
    box.setPadding(boxPadding);//from  w  ww .ja  v  a  2  s  .co m
    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);

}