Note that there are some explanatory texts on larger screens.

plurals
  1. POsetButtonCell for ComboBox
    text
    copied!<p>I have a problem which I cannot solve. I want to implement progress bar into combo box:</p> <pre><code>public class JavaFXApplication4 extends Application { @Override public void start(Stage primaryStage) { double y1 = 15; ProgressBar p1 = new ProgressBar(); p1.setLayoutY(y1); HBox vb1 = new HBox(10); vb1.getChildren().addAll(new Label("Progressbar 1"), p1); double y2 = 15; ProgressBar p2 = new ProgressBar(); p2.setLayoutY(y2); HBox vb2 = new HBox(10); vb2.getChildren().addAll(new Label("Progressbar 2"), p2); double y3 = 15; ProgressBar p3 = new ProgressBar(); p3.setLayoutY(y3); HBox vb3 = new HBox(10); vb3.getChildren().addAll(new Label("Progressbar 3"), p3); TextChooser textChooser = new TextChooser( vb1, vb2, vb3 ); textChooser.setStyle("-fx-font: 10px \"Verdana\";"); StackPane root = new StackPane(); root.getChildren().add(textChooser); Scene scene = new Scene(root, 300, 250); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); } public static class TextChooser extends StackPane { private Label label = new Label(); private ComboBox&lt;HBox&gt; combo = new ComboBox&lt;&gt;(); public TextChooser(HBox... options) { StackPane.setAlignment(label, Pos.CENTER_LEFT); StackPane.setAlignment(combo, Pos.CENTER_LEFT); label.graphicProperty().bind( //combo.getSelectionModel().selectedItemProperty() combo.getSelectionModel().selectedItemProperty() ); label.visibleProperty().bind( combo.visibleProperty().not() ); //label.setPadding(new Insets(0, 0, 0, 10)); combo.getItems().setAll(options); combo.setCellFactory(new Callback&lt;ListView&lt;HBox&gt;, ListCell&lt;HBox&gt;&gt;() { @Override public ListCell&lt;HBox&gt; call(ListView&lt;HBox&gt; p) { return new ListCell&lt;HBox&gt;() { @Override protected void updateItem(HBox item, boolean empty) { super.updateItem(item, empty); if (item == null || empty) { setGraphic(null); } else { setGraphic(item); } } }; } }); combo.getSelectionModel().select(0); combo.setVisible(true); label.setOnMouseEntered(event -&gt; combo.setVisible(true)); combo.showingProperty().addListener(observable -&gt; { if (!combo.isShowing()) { combo.setVisible(false); } }); combo.setOnMouseExited(event -&gt; { if (!combo.isShowing()) { combo.setVisible(false); } }); getChildren().setAll(label, combo); } public static void main(String[] args) { launch(args); } } } </code></pre> <p>Can you tell me how I have to use <code>setButtonCell</code> in order to display Progressbar into the Combo Box?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload