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

The following examples show how to use javafx.scene.control.ComboBox#setButtonCell() . 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: ColorInputPane.java    From constellation with Apache License 2.0 8 votes vote down vote up
private ComboBox<ConstellationColor> makeNamedCombo() {
    final ObservableList<ConstellationColor> namedColors = FXCollections.observableArrayList();
    for (final ConstellationColor c : ConstellationColor.NAMED_COLOR_LIST) {
        namedColors.add(c);
    }
    final ComboBox<ConstellationColor> namedCombo = new ComboBox<>(namedColors);
    namedCombo.setValue(ConstellationColor.WHITE);
    final Callback<ListView<ConstellationColor>, ListCell<ConstellationColor>> cellFactory = (final ListView<ConstellationColor> p) -> new ListCell<ConstellationColor>() {
        @Override
        protected void updateItem(final ConstellationColor item, boolean empty) {
            super.updateItem(item, empty);
            if (item != null) {
                final Rectangle r = new Rectangle(12, 12, item.getJavaFXColor());
                r.setStroke(Color.BLACK);
                setText(item.getName());
                setGraphic(r);
            }
        }
    };
    namedCombo.setCellFactory(cellFactory);
    namedCombo.setButtonCell(cellFactory.call(null));

    return namedCombo;
}
 
Example 2
Source File: TraceAUtilityNetworkController.java    From arcgis-runtime-samples-java with Apache License 2.0 6 votes vote down vote up
/**
 * Prompts the user to select a terminal from a provided list.
 *
 * @param terminals a list of terminals for the user to choose from
 * @return the user's selected terminal
 */
private Optional<UtilityTerminal> promptForTerminalSelection(List<UtilityTerminal> terminals) {

  // create a dialog for terminal selection
  ChoiceDialog<UtilityTerminal> utilityTerminalSelectionDialog = new ChoiceDialog<>(terminals.get(0), terminals);
  utilityTerminalSelectionDialog.initOwner(mapView.getScene().getWindow());
  utilityTerminalSelectionDialog.setTitle("Choose Utility Terminal");
  utilityTerminalSelectionDialog.setHeaderText("Junction selected. Choose the Utility Terminal to add as the trace element:");

  // override the list cell in the dialog's combo box to show the terminal name
  @SuppressWarnings("unchecked") ComboBox<UtilityTerminal> comboBox =
      (ComboBox<UtilityTerminal>) ((GridPane) utilityTerminalSelectionDialog.getDialogPane()
          .getContent()).getChildren().get(1);
  comboBox.setCellFactory(param -> new UtilityTerminalListCell());
  comboBox.setButtonCell(new UtilityTerminalListCell());

  // show the terminal selection dialog and capture the user selection
  return utilityTerminalSelectionDialog.showAndWait();
}
 
Example 3
Source File: AudioConfigurationView.java    From beatoraja with GNU General Public License v3.0 5 votes vote down vote up
private void initComboBox(ComboBox<Integer> combo, final String[] values) {
	combo.setCellFactory((param) -> new OptionListCell(values));
	combo.setButtonCell(new OptionListCell(values));
	for (int i = 0; i < values.length; i++) {
		combo.getItems().add(i);
	}
}
 
Example 4
Source File: IRConfigurationView.java    From beatoraja with GNU General Public License v3.0 5 votes vote down vote up
private void initComboBox(ComboBox<Integer> combo, final String[] values) {
	combo.setCellFactory((param) -> new OptionListCell(values));
	combo.setButtonCell(new OptionListCell(values));
	for (int i = 0; i < values.length; i++) {
		combo.getItems().add(i);
	}
}
 
Example 5
Source File: MainView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private Tuple2<ComboBox<PriceFeedComboBoxItem>, VBox> getMarketPriceBox() {

        VBox marketPriceBox = new VBox();
        marketPriceBox.setAlignment(Pos.CENTER_LEFT);

        ComboBox<PriceFeedComboBoxItem> priceComboBox = new JFXComboBox<>();
        priceComboBox.setVisibleRowCount(12);
        priceComboBox.setFocusTraversable(false);
        priceComboBox.setId("price-feed-combo");
        priceComboBox.setPadding(new Insets(0, -4, -4, 0));
        priceComboBox.setCellFactory(p -> getPriceFeedComboBoxListCell());
        ListCell<PriceFeedComboBoxItem> buttonCell = getPriceFeedComboBoxListCell();
        buttonCell.setId("price-feed-combo");
        priceComboBox.setButtonCell(buttonCell);

        Label marketPriceLabel = new Label();

        updateMarketPriceLabel(marketPriceLabel);

        marketPriceLabel.getStyleClass().add("nav-balance-label");
        marketPriceLabel.setPadding(new Insets(-2, 0, 4, 9));

        marketPriceBox.getChildren().addAll(priceComboBox, marketPriceLabel);

        model.getMarketPriceUpdated().addListener((observable, oldValue, newValue) ->
                updateMarketPriceLabel(marketPriceLabel));

        return new Tuple2<>(priceComboBox, marketPriceBox);
    }
 
Example 6
Source File: JFXWidgetCreator.java    From latexdraw with GNU General Public License v3.0 4 votes vote down vote up
default <T> void initComboBox(final ComboBox<T> box, final Map<T, Image> map, final T[] values) {
	final ComboBoxFactoryList<T> factory = new ComboBoxFactoryList<>(map);
	box.getItems().addAll(values);
	box.setButtonCell(factory.call(null));
	box.setCellFactory(factory);
}