Example usage for javafx.scene.control ComboBox setItems

List of usage examples for javafx.scene.control ComboBox setItems

Introduction

In this page you can find the example usage for javafx.scene.control ComboBox setItems.

Prototype

public final void setItems(ObservableList<T> value) 

Source Link

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);
    ObservableList<String> list = FXCollections.observableArrayList("1", "2", "3", "4");
    ComboBox<String> emailComboBox = new ComboBox<String>();
    emailComboBox.setItems(list);
    emailComboBox.setValue("A");

    GridPane grid = new GridPane();
    grid.setVgap(4);/*from   ww w  . j  a  v  a2s  .  co  m*/
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(emailComboBox, 1, 0);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();

}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);
    ObservableList<String> list = FXCollections.observableArrayList("1", "2", "3", "4");
    ComboBox<String> emailComboBox = new ComboBox<String>();
    emailComboBox.setItems(list);
    emailComboBox.setValue("A");

    System.out.println(emailComboBox.visibleRowCountProperty());

    GridPane grid = new GridPane();
    grid.setVgap(4);/*w w  w  .  j  av a2 s .  co m*/
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(emailComboBox, 1, 0);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();

}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group(), 450, 250);
    ObservableList<String> list = FXCollections.observableArrayList("1", "2", "3", "4");
    ComboBox<String> emailComboBox = new ComboBox<String>();
    emailComboBox.setItems(list);
    emailComboBox.setValue("A");

    StringConverter sc = new ShortStringConverter();
    emailComboBox.setConverter(sc);/*from   www.  j  a va2 s .  co m*/

    GridPane grid = new GridPane();
    grid.setVgap(4);
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("To: "), 0, 0);
    grid.add(emailComboBox, 1, 0);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();

}

From source file:statos2_0.StatOS2_0.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("");

    GridPane root = new GridPane();
    Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize();
    root.setAlignment(Pos.CENTER);//w w w  .j av  a2  s . c  o m
    root.setHgap(10);
    root.setVgap(10);
    root.setPadding(new Insets(25, 25, 25, 25));

    Text scenetitle = new Text("");

    root.add(scenetitle, 0, 0, 2, 1);
    scenetitle.setId("welcome-text");
    Label userName = new Label(":");
    //userName.setId("label");
    root.add(userName, 0, 1);

    TextField userTextField = new TextField();
    root.add(userTextField, 1, 1);

    Label pw = new Label(":");
    root.add(pw, 0, 2);

    PasswordField pwBox = new PasswordField();
    root.add(pwBox, 1, 2);
    ComboBox store = new ComboBox();
    store.setItems(GetByTag());
    root.add(store, 1, 3);

    Button btn = new Button("");
    //btn.setPrefSize(100, 20);
    HBox hbBtn = new HBox(10);
    hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn.getChildren().add(btn);

    root.add(hbBtn, 1, 4);

    Button btn2 = new Button("");
    //btn2.setPrefSize(100, 20);
    HBox hbBtn2 = new HBox(10);
    hbBtn2.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn2.getChildren().add(btn2);
    root.add(hbBtn2, 1, 5);

    final Text actiontarget = new Text();
    root.add(actiontarget, 1, 6);

    btn2.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            System.exit(0);
        }
    });

    btn.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            if (userTextField.getText().equals("")) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   !");
                alert.showAndWait();
            } else if (pwBox.getText().equals("")) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   !");
                alert.showAndWait();
            } else if (store.getSelectionModel().getSelectedIndex() < 0) {
                Alert alert = new Alert(Alert.AlertType.ERROR);
                alert.setTitle("!");
                alert.setHeaderText("!");
                alert.setContentText("   !");
                alert.showAndWait();
            } else {
                try {
                    String[] resu = checkpas(userTextField.getText(), pwBox.getText());
                    if (resu[0].equals("-1")) {
                        Alert alert = new Alert(Alert.AlertType.ERROR);
                        alert.setTitle("!");
                        alert.setHeaderText("!");
                        alert.setContentText("   !");
                        alert.showAndWait();
                    } else if (storecheck((store.getSelectionModel().getSelectedIndex() + 1)) == false) {
                        Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
                        alert.setTitle("!");
                        alert.setHeaderText("!");
                        alert.setContentText("     !"
                                + "\n       -  ");
                        Optional<ButtonType> result = alert.showAndWait();
                        if (result.get() == ButtonType.OK) {
                            // ... user chose OK
                            idstore = store.getSelectionModel().getSelectedIndex() + 1;
                            updsel(idstore, Integer.parseInt(resu[0]));
                            MainA ma = new MainA();
                            ma.m = (idstore);
                            ma.MT = "m" + idstore;
                            ma.selid = Integer.parseInt(resu[0]);
                            ma.nameseller = resu[1];
                            ma.storename = store.getSelectionModel().getSelectedItem().toString();
                            ma.start(primaryStage);
                        } else {
                            // ... user chose CANCEL or closed the dialog
                        }

                    } else {
                        // 

                        idstore = store.getSelectionModel().getSelectedIndex() + 1;
                        updsel(idstore, Integer.parseInt(resu[0]));
                        MainA ma = new MainA();
                        ma.m = (idstore);
                        ma.MT = "m" + idstore;
                        ma.selid = Integer.parseInt(resu[0]);
                        ma.nameseller = resu[1];
                        ma.storename = store.getSelectionModel().getSelectedItem().toString();

                        ma.start(primaryStage);

                    }

                } catch (NoSuchAlgorithmException ex) {
                    Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex);
                } catch (Exception ex) {
                    Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            /**
             * if((userTextField.getText().equals("admin"))&(pwBox.getText().equals("admin"))){
             * actiontarget.setId("acttrue");
             * actiontarget.setText(" !");
             * MainA ma = new MainA();
             * ma.m=1;
             * try {
             * ma.m=1;
             * ma.MT="m1";
             * ma.start(primaryStage);
             * } catch (Exception ex) {
             * Logger.getLogger(StatOS2_0.class.getName()).log(Level.SEVERE, null, ex);
             * }
             * }else{
             * actiontarget.setId("actfalse");
             * actiontarget.setText(" !");
             * } **/

        }
    });
    //Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize();
    //sSize.getHeight();
    Scene scene = new Scene(root, sSize.getWidth(), sSize.getHeight());

    primaryStage.setScene(scene);
    scene.getStylesheets().add(StatOS2_0.class.getResource("adminStatOS.css").toExternalForm());
    primaryStage.show();
}

From source file:io.bitsquare.gui.components.paymentmethods.BankForm.java

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

    Tuple3<Label, ComboBox, ComboBox> tuple3 = addLabelComboBoxComboBox(gridPane, ++gridRow, "Country:");

    ComboBox<Region> regionComboBox = tuple3.second;
    regionComboBox.setPromptText("Select region");
    regionComboBox.setConverter(new StringConverter<Region>() {
        @Override
        public String toString(Region region) {
            return region.name;
        }

        @Override
        public Region fromString(String s) {
            return null;
        }
    });
    regionComboBox.setItems(FXCollections.observableArrayList(CountryUtil.getAllRegions()));

    ComboBox<Country> countryComboBox = tuple3.third;
    countryComboBox.setVisibleRowCount(15);
    countryComboBox.setDisable(true);
    countryComboBox.setPromptText("Select country");
    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();
        if (selectedItem != null) {
            if (selectedItem.code.equals("US")) {
                new Popup<>().information(
                        "Bank transfer with WIRE or ACH is not supported for the US because WIRE is too expensive and ACH has a high chargeback risk.\n\n"
                                + "Please use payment methods \"ClearXchange\", \"US Postal Money Order\" or \"Cash/ATM Deposit\" instead.")
                        .onClose(() -> closeHandler.run()).show();
            } else {
                getCountryBasedPaymentAccount().setCountry(selectedItem);
                String countryCode = selectedItem.code;
                TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(countryCode);
                paymentAccount.setSingleTradeCurrency(currency);
                currencyComboBox.setDisable(false);
                currencyComboBox.getSelectionModel().select(currency);

                bankIdLabel.setText(BankUtil.getBankIdLabel(countryCode));
                branchIdLabel.setText(BankUtil.getBranchIdLabel(countryCode));
                accountNrLabel.setText(BankUtil.getAccountNrLabel(countryCode));
                accountTypeLabel.setText(BankUtil.getAccountTypeLabel(countryCode));

                bankNameInputTextField.setText("");
                bankIdInputTextField.setText("");
                branchIdInputTextField.setText("");
                accountNrInputTextField.setText("");
                accountTypeComboBox.getSelectionModel().clearSelection();
                accountTypeComboBox.setItems(
                        FXCollections.observableArrayList(BankUtil.getAccountTypeValues(countryCode)));

                if (BankUtil.useValidation(countryCode) && !validatorsApplied) {
                    validatorsApplied = true;
                    if (useHolderID)
                        holderIdInputTextField.setValidator(inputValidator);
                    bankNameInputTextField.setValidator(inputValidator);
                    bankIdInputTextField.setValidator(new BankIdValidator(countryCode));
                    branchIdInputTextField.setValidator(new BranchIdValidator(countryCode));
                    accountNrInputTextField.setValidator(new AccountNrValidator(countryCode));
                } else {
                    validatorsApplied = false;
                    if (useHolderID)
                        holderIdInputTextField.setValidator(null);
                    bankNameInputTextField.setValidator(null);
                    bankIdInputTextField.setValidator(null);
                    branchIdInputTextField.setValidator(null);
                    accountNrInputTextField.setValidator(null);
                }
                holderNameInputTextField.resetValidation();
                bankNameInputTextField.resetValidation();
                bankIdInputTextField.resetValidation();
                branchIdInputTextField.resetValidation();
                accountNrInputTextField.resetValidation();

                boolean requiresHolderId = BankUtil.isHolderIdRequired(countryCode);
                if (requiresHolderId) {
                    holderNameInputTextField.minWidthProperty().unbind();
                    holderNameInputTextField.setMinWidth(300);
                } else {
                    holderNameInputTextField.minWidthProperty().bind(currencyComboBox.widthProperty());
                }

                if (useHolderID) {
                    if (!requiresHolderId)
                        holderIdInputTextField.setText("");

                    holderIdInputTextField.resetValidation();
                    holderIdInputTextField.setVisible(requiresHolderId);
                    holderIdInputTextField.setManaged(requiresHolderId);

                    holderIdLabel.setText(BankUtil.getHolderIdLabel(countryCode));
                    holderIdLabel.setVisible(requiresHolderId);
                    holderIdLabel.setManaged(requiresHolderId);
                }

                boolean bankNameRequired = BankUtil.isBankNameRequired(countryCode);
                bankNameTuple.first.setVisible(bankNameRequired);
                bankNameTuple.first.setManaged(bankNameRequired);
                bankNameInputTextField.setVisible(bankNameRequired);
                bankNameInputTextField.setManaged(bankNameRequired);

                boolean bankIdRequired = BankUtil.isBankIdRequired(countryCode);
                bankIdTuple.first.setVisible(bankIdRequired);
                bankIdTuple.first.setManaged(bankIdRequired);
                bankIdInputTextField.setVisible(bankIdRequired);
                bankIdInputTextField.setManaged(bankIdRequired);

                boolean branchIdRequired = BankUtil.isBranchIdRequired(countryCode);
                branchIdTuple.first.setVisible(branchIdRequired);
                branchIdTuple.first.setManaged(branchIdRequired);
                branchIdInputTextField.setVisible(branchIdRequired);
                branchIdInputTextField.setManaged(branchIdRequired);

                boolean accountNrRequired = BankUtil.isAccountNrRequired(countryCode);
                accountNrTuple.first.setVisible(accountNrRequired);
                accountNrTuple.first.setManaged(accountNrRequired);
                accountNrInputTextField.setVisible(accountNrRequired);
                accountNrInputTextField.setManaged(accountNrRequired);

                boolean accountTypeRequired = BankUtil.isAccountTypeRequired(countryCode);
                accountTypeTuple.first.setVisible(accountTypeRequired);
                accountTypeTuple.first.setManaged(accountTypeRequired);
                accountTypeTuple.second.setVisible(accountTypeRequired);
                accountTypeTuple.second.setManaged(accountTypeRequired);

                updateFromInputs();

                onCountryChanged();
            }
        }
    });

    regionComboBox.setOnAction(e -> {
        Region selectedItem = regionComboBox.getSelectionModel().getSelectedItem();
        if (selectedItem != null) {
            countryComboBox.setDisable(false);
            countryComboBox.setItems(
                    FXCollections.observableArrayList(CountryUtil.getAllCountriesForRegion(selectedItem)));
        }
    });

    currencyComboBox = addLabelComboBox(gridPane, ++gridRow, "Currency:").second;
    currencyComboBox.setPromptText("Select currency");
    currencyComboBox.setItems(FXCollections.observableArrayList(CurrencyUtil.getAllSortedFiatCurrencies()));
    currencyComboBox.setOnAction(e -> {
        TradeCurrency selectedItem = currencyComboBox.getSelectionModel().getSelectedItem();
        FiatCurrency defaultCurrency = CurrencyUtil
                .getCurrencyByCountryCode(countryComboBox.getSelectionModel().getSelectedItem().code);
        if (!defaultCurrency.equals(selectedItem)) {
            new Popup<>().warning(
                    "Are you sure you want to choose a currency other than the country's default currency?")
                    .actionButtonText("Yes").onAction(() -> {
                        paymentAccount.setSingleTradeCurrency(selectedItem);
                        autoFillNameTextField();
                    }).closeButtonText("No, restore default currency")
                    .onClose(() -> currencyComboBox.getSelectionModel().select(defaultCurrency)).show();
        } else {
            paymentAccount.setSingleTradeCurrency(selectedItem);
            autoFillNameTextField();
        }
    });
    currencyComboBox.setConverter(new StringConverter<TradeCurrency>() {
        @Override
        public String toString(TradeCurrency currency) {
            return currency.getNameAndCode();
        }

        @Override
        public TradeCurrency fromString(String string) {
            return null;
        }
    });
    currencyComboBox.setDisable(true);

    addAcceptedBanksForAddAccount();

    addHolderNameAndId();

    bankNameTuple = addLabelInputTextField(gridPane, ++gridRow, "Bank name:");
    bankNameInputTextField = bankNameTuple.second;

    bankNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        bankAccountContractData.setBankName(newValue);
        updateFromInputs();

    });

    bankIdTuple = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getBankIdLabel(""));
    bankIdLabel = bankIdTuple.first;
    bankIdInputTextField = bankIdTuple.second;
    bankIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        bankAccountContractData.setBankId(newValue);
        updateFromInputs();

    });

    branchIdTuple = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getBranchIdLabel(""));
    branchIdLabel = branchIdTuple.first;
    branchIdInputTextField = branchIdTuple.second;
    branchIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        bankAccountContractData.setBranchId(newValue);
        updateFromInputs();

    });

    accountNrTuple = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getAccountNrLabel(""));
    accountNrLabel = accountNrTuple.first;
    accountNrInputTextField = accountNrTuple.second;
    accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        bankAccountContractData.setAccountNr(newValue);
        updateFromInputs();

    });

    accountTypeTuple = addLabelComboBox(gridPane, ++gridRow, "");
    accountTypeLabel = accountTypeTuple.first;
    accountTypeComboBox = accountTypeTuple.second;
    accountTypeComboBox.setPromptText("Select account type");
    accountTypeComboBox.setOnAction(e -> {
        if (BankUtil.isAccountTypeRequired(bankAccountContractData.getCountryCode())) {
            bankAccountContractData.setAccountType(accountTypeComboBox.getSelectionModel().getSelectedItem());
            updateFromInputs();
        }
    });

    addAllowedPeriod();
    addAccountNameTextFieldWithAutoFillCheckBox();

    updateFromInputs();
}

From source file:io.bitsquare.gui.components.paymentmethods.CashDepositForm.java

@Override
public void addFormForAddAccount() {
    gridRowFrom = gridRow + 1;/*from w ww.  j av a  2 s. com*/

    Tuple3<Label, ComboBox, ComboBox> tuple3 = addLabelComboBoxComboBox(gridPane, ++gridRow, "Country:");

    ComboBox<Region> regionComboBox = tuple3.second;
    regionComboBox.setPromptText("Select region");
    regionComboBox.setConverter(new StringConverter<Region>() {
        @Override
        public String toString(Region region) {
            return region.name;
        }

        @Override
        public Region fromString(String s) {
            return null;
        }
    });
    regionComboBox.setItems(FXCollections.observableArrayList(CountryUtil.getAllRegions()));

    ComboBox<Country> countryComboBox = tuple3.third;
    countryComboBox.setVisibleRowCount(15);
    countryComboBox.setDisable(true);
    countryComboBox.setPromptText("Select country");
    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();
        if (selectedItem != null) {
            getCountryBasedPaymentAccount().setCountry(selectedItem);
            String countryCode = selectedItem.code;
            TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(countryCode);
            paymentAccount.setSingleTradeCurrency(currency);
            currencyComboBox.setDisable(false);
            currencyComboBox.getSelectionModel().select(currency);

            bankIdLabel.setText(BankUtil.getBankIdLabel(countryCode));
            branchIdLabel.setText(BankUtil.getBranchIdLabel(countryCode));
            accountNrLabel.setText(BankUtil.getAccountNrLabel(countryCode));
            accountTypeLabel.setText(BankUtil.getAccountTypeLabel(countryCode));

            bankNameInputTextField.setText("");
            bankIdInputTextField.setText("");
            branchIdInputTextField.setText("");
            accountNrInputTextField.setText("");
            accountTypeComboBox.getSelectionModel().clearSelection();
            accountTypeComboBox
                    .setItems(FXCollections.observableArrayList(BankUtil.getAccountTypeValues(countryCode)));

            if (BankUtil.useValidation(countryCode) && !validatorsApplied) {
                validatorsApplied = true;
                if (useHolderID)
                    holderIdInputTextField.setValidator(inputValidator);
                bankNameInputTextField.setValidator(inputValidator);
                bankIdInputTextField.setValidator(new BankIdValidator(countryCode));
                branchIdInputTextField.setValidator(new BranchIdValidator(countryCode));
                accountNrInputTextField.setValidator(new AccountNrValidator(countryCode));
            } else {
                validatorsApplied = false;
                if (useHolderID)
                    holderIdInputTextField.setValidator(null);
                bankNameInputTextField.setValidator(null);
                bankIdInputTextField.setValidator(null);
                branchIdInputTextField.setValidator(null);
                accountNrInputTextField.setValidator(null);
            }
            holderNameInputTextField.resetValidation();
            holderEmailInputTextField.resetValidation();
            bankNameInputTextField.resetValidation();
            bankIdInputTextField.resetValidation();
            branchIdInputTextField.resetValidation();
            accountNrInputTextField.resetValidation();

            boolean requiresHolderId = BankUtil.isHolderIdRequired(countryCode);
            if (requiresHolderId) {
                holderNameInputTextField.minWidthProperty().unbind();
                holderNameInputTextField.setMinWidth(300);
            } else {
                holderNameInputTextField.minWidthProperty().bind(currencyComboBox.widthProperty());
            }

            if (useHolderID) {
                if (!requiresHolderId)
                    holderIdInputTextField.setText("");

                holderIdInputTextField.resetValidation();
                holderIdInputTextField.setVisible(requiresHolderId);
                holderIdInputTextField.setManaged(requiresHolderId);

                holderIdLabel.setText(BankUtil.getHolderIdLabel(countryCode));
                holderIdLabel.setVisible(requiresHolderId);
                holderIdLabel.setManaged(requiresHolderId);
            }

            boolean bankNameRequired = BankUtil.isBankNameRequired(countryCode);
            bankNameTuple.first.setVisible(bankNameRequired);
            bankNameTuple.first.setManaged(bankNameRequired);
            bankNameInputTextField.setVisible(bankNameRequired);
            bankNameInputTextField.setManaged(bankNameRequired);

            boolean bankIdRequired = BankUtil.isBankIdRequired(countryCode);
            bankIdTuple.first.setVisible(bankIdRequired);
            bankIdTuple.first.setManaged(bankIdRequired);
            bankIdInputTextField.setVisible(bankIdRequired);
            bankIdInputTextField.setManaged(bankIdRequired);

            boolean branchIdRequired = BankUtil.isBranchIdRequired(countryCode);
            branchIdTuple.first.setVisible(branchIdRequired);
            branchIdTuple.first.setManaged(branchIdRequired);
            branchIdInputTextField.setVisible(branchIdRequired);
            branchIdInputTextField.setManaged(branchIdRequired);

            boolean accountNrRequired = BankUtil.isAccountNrRequired(countryCode);
            accountNrTuple.first.setVisible(accountNrRequired);
            accountNrTuple.first.setManaged(accountNrRequired);
            accountNrInputTextField.setVisible(accountNrRequired);
            accountNrInputTextField.setManaged(accountNrRequired);

            boolean accountTypeRequired = BankUtil.isAccountTypeRequired(countryCode);
            accountTypeTuple.first.setVisible(accountTypeRequired);
            accountTypeTuple.first.setManaged(accountTypeRequired);
            accountTypeTuple.second.setVisible(accountTypeRequired);
            accountTypeTuple.second.setManaged(accountTypeRequired);

            updateFromInputs();

            onCountryChanged();
        }
    });

    regionComboBox.setOnAction(e -> {
        Region selectedItem = regionComboBox.getSelectionModel().getSelectedItem();
        if (selectedItem != null) {
            countryComboBox.setDisable(false);
            countryComboBox.setItems(
                    FXCollections.observableArrayList(CountryUtil.getAllCountriesForRegion(selectedItem)));
        }
    });

    currencyComboBox = addLabelComboBox(gridPane, ++gridRow, "Currency:").second;
    currencyComboBox.setPromptText("Select currency");
    currencyComboBox.setItems(FXCollections.observableArrayList(CurrencyUtil.getAllSortedFiatCurrencies()));
    currencyComboBox.setOnAction(e -> {
        TradeCurrency selectedItem = currencyComboBox.getSelectionModel().getSelectedItem();
        FiatCurrency defaultCurrency = CurrencyUtil
                .getCurrencyByCountryCode(countryComboBox.getSelectionModel().getSelectedItem().code);
        if (!defaultCurrency.equals(selectedItem)) {
            new Popup<>().warning(
                    "Are you sure you want to choose a currency other than the country's default currency?")
                    .actionButtonText("Yes").onAction(() -> {
                        paymentAccount.setSingleTradeCurrency(selectedItem);
                        autoFillNameTextField();
                    }).closeButtonText("No, restore default currency")
                    .onClose(() -> currencyComboBox.getSelectionModel().select(defaultCurrency)).show();
        } else {
            paymentAccount.setSingleTradeCurrency(selectedItem);
            autoFillNameTextField();
        }
    });
    currencyComboBox.setConverter(new StringConverter<TradeCurrency>() {
        @Override
        public String toString(TradeCurrency currency) {
            return currency.getNameAndCode();
        }

        @Override
        public TradeCurrency fromString(String string) {
            return null;
        }
    });
    currencyComboBox.setDisable(true);

    addAcceptedBanksForAddAccount();

    addHolderNameAndId();

    bankNameTuple = addLabelInputTextField(gridPane, ++gridRow, "Bank name:");
    bankNameInputTextField = bankNameTuple.second;

    bankNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        cashDepositAccountContractData.setBankName(newValue);
        updateFromInputs();

    });

    bankIdTuple = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getBankIdLabel(""));
    bankIdLabel = bankIdTuple.first;
    bankIdInputTextField = bankIdTuple.second;
    bankIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        cashDepositAccountContractData.setBankId(newValue);
        updateFromInputs();

    });

    branchIdTuple = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getBranchIdLabel(""));
    branchIdLabel = branchIdTuple.first;
    branchIdInputTextField = branchIdTuple.second;
    branchIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        cashDepositAccountContractData.setBranchId(newValue);
        updateFromInputs();

    });

    accountNrTuple = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getAccountNrLabel(""));
    accountNrLabel = accountNrTuple.first;
    accountNrInputTextField = accountNrTuple.second;
    accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
        cashDepositAccountContractData.setAccountNr(newValue);
        updateFromInputs();

    });

    accountTypeTuple = addLabelComboBox(gridPane, ++gridRow, "");
    accountTypeLabel = accountTypeTuple.first;
    accountTypeComboBox = accountTypeTuple.second;
    accountTypeComboBox.setPromptText("Select account type");
    accountTypeComboBox.setOnAction(e -> {
        if (BankUtil.isAccountTypeRequired(cashDepositAccountContractData.getCountryCode())) {
            cashDepositAccountContractData
                    .setAccountType(accountTypeComboBox.getSelectionModel().getSelectedItem());
            updateFromInputs();
        }
    });

    TextArea requirementsTextArea = addLabelTextArea(gridPane, ++gridRow, "Extra requirements:", "").second;
    requirementsTextArea.setMinHeight(30);
    requirementsTextArea.setMaxHeight(30);
    requirementsTextArea.textProperty().addListener((ov, oldValue, newValue) -> {
        cashDepositAccountContractData.setRequirements(newValue);
        updateFromInputs();
    });

    addAllowedPeriod();
    addAccountNameTextFieldWithAutoFillCheckBox();

    updateFromInputs();
}

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:qupath.lib.gui.tma.TMASummaryViewer.java

private Pane getCustomizeTablePane() {
    TableView<TreeTableColumn<TMAEntry, ?>> tableColumns = new TableView<>();
    tableColumns.setPlaceholder(new Text("No columns available"));
    tableColumns.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    tableColumns.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    SortedList<TreeTableColumn<TMAEntry, ?>> sortedColumns = new SortedList<>(
            table.getColumns().filtered(p -> !p.getText().trim().isEmpty()));
    sortedColumns.setComparator((c1, c2) -> c1.getText().compareTo(c2.getText()));
    tableColumns.setItems(sortedColumns);
    sortedColumns.comparatorProperty().bind(tableColumns.comparatorProperty());
    //      sortedColumns.comparatorProperty().bind(tableColumns.comparatorProperty());

    TableColumn<TreeTableColumn<TMAEntry, ?>, String> columnName = new TableColumn<>("Column");
    columnName.setCellValueFactory(v -> v.getValue().textProperty());
    TableColumn<TreeTableColumn<TMAEntry, ?>, Boolean> columnVisible = new TableColumn<>("Visible");
    columnVisible.setCellValueFactory(v -> v.getValue().visibleProperty());
    //      columnVisible.setCellValueFactory(col -> {
    //         SimpleBooleanProperty prop = new SimpleBooleanProperty(col.getValue().isVisible());
    //         prop.addListener((v, o, n) -> col.getValue().setVisible(n));
    //         return prop;
    //      });//from  w ww  .j  a  va 2 s  .com
    tableColumns.setEditable(true);
    columnVisible.setCellFactory(v -> new CheckBoxTableCell<>());
    tableColumns.getColumns().add(columnName);
    tableColumns.getColumns().add(columnVisible);
    ContextMenu contextMenu = new ContextMenu();

    Action actionShowSelected = new Action("Show selected", e -> {
        for (TreeTableColumn<?, ?> col : tableColumns.getSelectionModel().getSelectedItems()) {
            if (col != null)
                col.setVisible(true);
            else {
                // Not sure why this happens...?
                logger.trace("Selected column is null!");
            }
        }
    });

    Action actionHideSelected = new Action("Hide selected", e -> {
        for (TreeTableColumn<?, ?> col : tableColumns.getSelectionModel().getSelectedItems()) {
            if (col != null)
                col.setVisible(false);
            else {
                // Not sure why this happens...?
                logger.trace("Selected column is null!");
            }
        }
    });

    contextMenu.getItems().addAll(ActionUtils.createMenuItem(actionShowSelected),
            ActionUtils.createMenuItem(actionHideSelected));
    tableColumns.setContextMenu(contextMenu);
    tableColumns.setTooltip(
            new Tooltip("Show or hide table columns - right-click to change multiple columns at once"));

    BorderPane paneColumns = new BorderPane(tableColumns);
    paneColumns.setBottom(PanelToolsFX.createColumnGridControls(ActionUtils.createButton(actionShowSelected),
            ActionUtils.createButton(actionHideSelected)));

    VBox paneRows = new VBox();

    // Create a box to filter on some metadata text
    ComboBox<String> comboMetadata = new ComboBox<>();
    comboMetadata.setItems(metadataNames);
    comboMetadata.getSelectionModel().getSelectedItem();
    comboMetadata.setPromptText("Select column");
    TextField tfFilter = new TextField();
    CheckBox cbExact = new CheckBox("Exact");
    // Set listeners
    cbExact.selectedProperty().addListener(
            (v, o, n) -> setMetadataTextPredicate(comboMetadata.getSelectionModel().getSelectedItem(),
                    tfFilter.getText(), cbExact.isSelected(), !cbExact.isSelected()));
    tfFilter.textProperty().addListener(
            (v, o, n) -> setMetadataTextPredicate(comboMetadata.getSelectionModel().getSelectedItem(),
                    tfFilter.getText(), cbExact.isSelected(), !cbExact.isSelected()));
    comboMetadata.getSelectionModel().selectedItemProperty().addListener(
            (v, o, n) -> setMetadataTextPredicate(comboMetadata.getSelectionModel().getSelectedItem(),
                    tfFilter.getText(), cbExact.isSelected(), !cbExact.isSelected()));

    GridPane paneMetadata = new GridPane();
    paneMetadata.add(comboMetadata, 0, 0);
    paneMetadata.add(tfFilter, 1, 0);
    paneMetadata.add(cbExact, 2, 0);
    paneMetadata.setPadding(new Insets(10, 10, 10, 10));
    paneMetadata.setVgap(2);
    paneMetadata.setHgap(5);
    comboMetadata.setMaxWidth(Double.MAX_VALUE);
    GridPane.setHgrow(tfFilter, Priority.ALWAYS);
    GridPane.setFillWidth(comboMetadata, Boolean.TRUE);
    GridPane.setFillWidth(tfFilter, Boolean.TRUE);

    TitledPane tpMetadata = new TitledPane("Metadata filter", paneMetadata);
    tpMetadata.setExpanded(false);
    //      tpMetadata.setCollapsible(false);
    Tooltip tooltipMetadata = new Tooltip(
            "Enter text to filter entries according to a selected metadata column");
    Tooltip.install(paneMetadata, tooltipMetadata);
    tpMetadata.setTooltip(tooltipMetadata);
    paneRows.getChildren().add(tpMetadata);

    // Add measurement predicate
    TextField tfCommand = new TextField();
    tfCommand.setTooltip(new Tooltip("Predicate used to filter entries for inclusion"));

    TextFields.bindAutoCompletion(tfCommand, e -> {
        int ind = tfCommand.getText().lastIndexOf("\"");
        if (ind < 0)
            return Collections.emptyList();
        String part = tfCommand.getText().substring(ind + 1);
        return measurementNames.stream().filter(n -> n.startsWith(part)).map(n -> "\"" + n + "\" ")
                .collect(Collectors.toList());
    });

    String instructions = "Enter a predicate to filter entries.\n"
            + "Only entries passing the test will be included in any results.\n"
            + "Examples of predicates include:\n" + "    \"Num Tumor\" > 200\n"
            + "    \"Num Tumor\" > 100 && \"Num Stroma\" < 1000";
    //      labelInstructions.setTooltip(new Tooltip("Note: measurement names must be in \"inverted commands\" and\n" + 
    //            "&& indicates 'and', while || indicates 'or'."));

    BorderPane paneMeasurementFilter = new BorderPane(tfCommand);
    Label label = new Label("Predicate: ");
    label.setAlignment(Pos.CENTER);
    label.setMaxHeight(Double.MAX_VALUE);
    paneMeasurementFilter.setLeft(label);

    Button btnApply = new Button("Apply");
    btnApply.setOnAction(e -> {
        TablePredicate predicateNew = new TablePredicate(tfCommand.getText());
        if (predicateNew.isValid()) {
            predicateMeasurements.set(predicateNew);
        } else {
            DisplayHelpers.showErrorMessage("Invalid predicate",
                    "Current predicate '" + tfCommand.getText() + "' is invalid!");
        }
        e.consume();
    });
    TitledPane tpMeasurementFilter = new TitledPane("Measurement filter", paneMeasurementFilter);
    tpMeasurementFilter.setExpanded(false);
    Tooltip tooltipInstructions = new Tooltip(instructions);
    tpMeasurementFilter.setTooltip(tooltipInstructions);
    Tooltip.install(paneMeasurementFilter, tooltipInstructions);
    paneMeasurementFilter.setRight(btnApply);

    paneRows.getChildren().add(tpMeasurementFilter);

    logger.info("Predicate set to: {}", predicateMeasurements.get());

    VBox pane = new VBox();
    //      TitledPane tpColumns = new TitledPane("Select column", paneColumns);
    //      tpColumns.setMaxHeight(Double.MAX_VALUE);
    //      tpColumns.setCollapsible(false);
    pane.getChildren().addAll(paneColumns, new Separator(), paneRows);
    VBox.setVgrow(paneColumns, Priority.ALWAYS);

    return pane;
}

From source file:UI.MainStageController.java

/**
 * Helper function to set new Palette Spetrum in ComboBox
 * @param cb ComboBox which should be adapted
 * @param p EnumSet of Palette values to be displayed
 *//*  w  w w.  jav a2s  . co m*/
private void setPalette(ComboBox cb, EnumSet p) {
    cb.setItems(FXCollections.observableArrayList(p));
    cb.getSelectionModel().selectFirst();
}