Java Code Examples for javafx.scene.control.ComboBox#setPromptText()

The following examples show how to use javafx.scene.control.ComboBox#setPromptText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GenericRootAndDatasetStructure.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
private Node createNode()
{
	final Node             groupField      = rootNode.get();
	final ComboBox<String> datasetDropDown = new ComboBox<>(datasetChoices);
	datasetDropDown.setPromptText(datasetPromptText);
	datasetDropDown.setEditable(false);
	datasetDropDown.valueProperty().bindBidirectional(dataset);
	datasetDropDown.disableProperty().bind(this.isDropDownReady);
	final GridPane grid = new GridPane();
	grid.add(groupField, 0, 0);
	grid.add(datasetDropDown, 0, 1);
	GridPane.setHgrow(groupField, Priority.ALWAYS);
	GridPane.setHgrow(datasetDropDown, Priority.ALWAYS);
	final Button button = new Button("Browse");
	button.setOnAction(event -> onBrowseClicked.accept(grid.getScene()));
	grid.add(button, 1, 0);

	return grid;
}
 
Example 2
Source File: ComboBoxSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public ComboBoxSample() {

        HBox hbox = HBoxBuilder.create().alignment(Pos.CENTER).spacing(15).build();
               
        //Non-editable combobox. Created with a builder
        ComboBox uneditableComboBox = ComboBoxBuilder.create()
                .id("uneditable-combobox")
                .promptText("Make a choice...")
                .items(FXCollections.observableArrayList(strings.subList(0, 8))).build();

        //Editable combobox. Use the default item display length
        ComboBox<String> editableComboBox = new ComboBox<String>();
        editableComboBox.setId("second-editable");
        editableComboBox.setPromptText("Edit or Choose...");
        editableComboBox.setItems(strings);
        editableComboBox.setEditable(true);

        hbox.getChildren().addAll(uneditableComboBox, editableComboBox);
        getChildren().add(hbox);
    }
 
Example 3
Source File: ComboBoxSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public ComboBoxSample() {

        HBox hbox = HBoxBuilder.create().alignment(Pos.CENTER).spacing(15).build();
               
        //Non-editable combobox. Created with a builder
        ComboBox uneditableComboBox = ComboBoxBuilder.create()
                .id("uneditable-combobox")
                .promptText("Make a choice...")
                .items(FXCollections.observableArrayList(strings.subList(0, 8))).build();

        //Editable combobox. Use the default item display length
        ComboBox<String> editableComboBox = new ComboBox<String>();
        editableComboBox.setId("second-editable");
        editableComboBox.setPromptText("Edit or Choose...");
        editableComboBox.setItems(strings);
        editableComboBox.setEditable(true);

        hbox.getChildren().addAll(uneditableComboBox, editableComboBox);
        getChildren().add(hbox);
    }
 
Example 4
Source File: RevolutForm.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
ComboBox<Country> addCountrySelection() {
    HBox hBox = new HBox();

    hBox.setSpacing(5);
    ComboBox<Country> countryComboBox = new JFXComboBox<>();
    hBox.getChildren().add(countryComboBox);

    addTopLabelWithVBox(gridPane, ++gridRow, Res.get("payment.bank.country"), hBox, 0);

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

        @Override
        public Country fromString(String s) {
            return null;
        }
    });
    return countryComboBox;
}
 
Example 5
Source File: TimelinePanel.java    From constellation with Apache License 2.0 5 votes vote down vote up
private ComboBox<String> createComboNodeLabels() {
    final ComboBox<String> newComboBox = new ComboBox<>();
    newComboBox.setPrefWidth(150.0);
    newComboBox.setVisible(false);
    newComboBox.setPromptText(Bundle.SelectLabelAttribute());
    newComboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
        if (oldValue == null && newValue != null) {
            coordinator.setNodeLabelsAttr(newValue);
        } else if (oldValue != null && newValue != null && !oldValue.equals(newValue)) {
            coordinator.setNodeLabelsAttr(newValue);
        }
    });

    //scroll on button only not drop downlist.
    newComboBox.setOnScroll(t -> {
        if (t.getDeltaY() < 0) {
            newComboBox.getSelectionModel().selectNext();
        } else if (t.getDeltaY() > 0) {

            newComboBox.getSelectionModel().selectPrevious();
        }
    });

    newComboBox.setVisibleRowCount(5);

    return newComboBox;
}
 
Example 6
Source File: GroupAndDatasetStructure.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public Node createNode()
{
	final TextField groupField = new TextField(group.getValue());
	groupField.setMinWidth(0);
	groupField.setMaxWidth(Double.POSITIVE_INFINITY);
	groupField.setPromptText(groupPromptText);
	groupField.textProperty().bindBidirectional(group);
	final ComboBox<String> datasetDropDown = new ComboBox<>(datasetChoices);
	datasetDropDown.setPromptText(datasetPromptText);
	datasetDropDown.setEditable(false);
	datasetDropDown.valueProperty().bindBidirectional(dataset);
	datasetDropDown.setMinWidth(groupField.getMinWidth());
	datasetDropDown.setPrefWidth(groupField.getPrefWidth());
	datasetDropDown.setMaxWidth(groupField.getMaxWidth());
	datasetDropDown.disableProperty().bind(this.isDropDownReady);
	final GridPane grid = new GridPane();
	grid.add(groupField, 0, 0);
	grid.add(datasetDropDown, 0, 1);
	GridPane.setHgrow(groupField, Priority.ALWAYS);
	GridPane.setHgrow(datasetDropDown, Priority.ALWAYS);
	final Button button = new Button("Browse");
	button.setOnAction(event -> {
		Optional.ofNullable(onBrowseClicked.apply(group.getValue(), grid.getScene())).ifPresent(group::setValue);
	});
	grid.add(button, 1, 0);

	groupField.effectProperty().bind(
			Bindings.createObjectBinding(
					() -> groupField.isFocused() ? this.textFieldNoErrorEffect : groupErrorEffect.get(),
					groupErrorEffect,
					groupField.focusedProperty()
			                            ));

	return grid;
}
 
Example 7
Source File: SelectableTitledPaneDemo.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
@Override 
	public void start(Stage stage) {
	        
		  List<String> list = new ArrayList<>(Arrays.asList(strs));
		  	  
//		  ComboBox<?> combo = ComboBoxBuilder.create().
//		            prefWidth(150).
//		            //items(list).
//		            items(FXCollections.observableArrayList(list)).//"aa", "bb", "bb")); 		  
//		            //promptText(resourceBundle.getString("search.prompt.owner")).
//		            promptText("Choice").
//		            build();
		 
		  ComboBox<String> combo = new ComboBox<String>();
		  combo.setItems(FXCollections.observableArrayList(list));
		  combo.setPrefWidth(150);
		  combo.setPromptText("Choice");

		  //combo.setItems((ObservableList<?>) FXCollections.observableArrayList(list));//"aa", "bb", "bb"));
		  
		  
		  SelectableTitledPane ownerParams = new SelectableTitledPane(
				  //resourceBundle.getString("search.checkbox.owner"),
				  "checkbox",
				  combo);

	        
	        StackPane pane = new StackPane();
	        pane.setBackground(null);
	        pane.setPadding(new Insets(10, 10, 10, 10));
	        pane.getChildren().addAll( ownerParams);

	        Scene scene = new Scene(pane);
	        stage.setScene(scene);
	        stage.show();
	    }
 
Example 8
Source File: FlyoutDemo.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates and returns demo widget
 * @return  the control for demo-ing widget
 */
public GridPane getStuffControl() {
    GridPane gp = new GridPane();
    gp.setPadding(new Insets(5, 5, 5, 5));
    gp.setHgap(5);
    
    ComboBox<String> stuffCombo = new ComboBox<>();
    stuffCombo.setEditable(true);
    stuffCombo.setPromptText("Add stuff...");
    stuffCombo.getItems().addAll(
        "Stuff",
        "contained",
        "within",
        "the",
        "combo"
    );
    
    Label l = new Label("Select or enter example text:");
    l.setFont(Font.font(l.getFont().getFamily(), 10));
    l.setTextFill(Color.WHITE);
    Button add = new Button("Add");
    add.setOnAction(e -> stuffCombo.getItems().add(stuffCombo.getSelectionModel().getSelectedItem()));
    Button del = new Button("Clear");
    del.setOnAction(e -> stuffCombo.getSelectionModel().clearSelection());
    gp.add(l, 0, 0, 2, 1);
    gp.add(stuffCombo, 0, 1, 2, 1);
    gp.add(add, 2, 1);
    gp.add(del, 3, 1);
    
    return gp;
}
 
Example 9
Source File: GUIUtil.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Tuple2<ComboBox<TradeCurrency>, Integer> addRegionCountryTradeCurrencyComboBoxes(GridPane gridPane,
                                                                                               int gridRow,
                                                                                               Consumer<Country> onCountrySelectedHandler,
                                                                                               Consumer<TradeCurrency> onTradeCurrencySelectedHandler) {
    gridRow = addRegionCountry(gridPane, gridRow, onCountrySelectedHandler);

    ComboBox<TradeCurrency> currencyComboBox = FormBuilder.addComboBox(gridPane, ++gridRow,
            Res.get("shared.currency"));
    currencyComboBox.setPromptText(Res.get("list.currency.select"));
    currencyComboBox.setItems(FXCollections.observableArrayList(CurrencyUtil.getAllSortedFiatCurrencies()));

    currencyComboBox.setConverter(new StringConverter<>() {
        @Override
        public String toString(TradeCurrency currency) {
            return currency.getNameAndCode();
        }

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

    currencyComboBox.setOnAction(e ->
            onTradeCurrencySelectedHandler.accept(currencyComboBox.getSelectionModel().getSelectedItem()));

    return new Tuple2<>(currencyComboBox, gridRow);
}
 
Example 10
Source File: GeneralSepaForm.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
ComboBox<Country> addCountrySelection() {
    HBox hBox = new HBox();

    hBox.setSpacing(10);
    ComboBox<Country> countryComboBox = new JFXComboBox<>();
    currencyTextField = new JFXTextField("");
    currencyTextField.setEditable(false);
    currencyTextField.setMouseTransparent(true);
    currencyTextField.setFocusTraversable(false);
    currencyTextField.setMinWidth(300);

    currencyTextField.setVisible(true);
    currencyTextField.setManaged(true);
    currencyTextField.setText(Res.get("payment.currencyWithSymbol", euroCurrency.getNameAndCode()));

    hBox.getChildren().addAll(countryComboBox, currencyTextField);

    addTopLabelWithVBox(gridPane, ++gridRow, Res.get("payment.bank.country"), hBox, 0);

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

        @Override
        public Country fromString(String s) {
            return null;
        }
    });
    return countryComboBox;
}