Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Hi peter use this code your drop down size increase but one problem choice box node size not increase.I will work that part if plz check this code</p> <pre><code>import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ComboBox; import javafx.scene.control.Label; import javafx.scene.control.ListCell; import javafx.scene.control.ListView; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; import javafx.util.Callback; /** * * @author reegan */ public class JavaFXComboBoxStack extends Application { @Override public void start(Stage primaryStage) { final ComboBox comboBox = new ComboBox(); comboBox.getItems().addAll( "Item 1", "Item 2", "Item 3", "Item 4"); comboBox.setValue( "Item 1"); comboBox.setMaxWidth(10); comboBox.setMaxSize(25, 25); comboBox.setCellFactory( new Callback&lt;ListView&lt;String&gt;, ListCell&lt;String&gt;&gt;() { @Override public ListCell&lt;String&gt; call(ListView&lt;String&gt; param) { final ListCell&lt;String&gt; cell = new ListCell&lt;String&gt;() { { super.setPrefWidth(10); // Set Drop Down Width } @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (item != null) { setText(item); } else { setText(null); } } }; return cell; } }); final Label label = new Label(); Button btn = new Button(); btn.setText("Read comboBox"); btn.setOnAction(new EventHandler&lt;ActionEvent&gt;() { @Override public void handle(ActionEvent event) { label.setText("selectd: " + comboBox.getValue()); } }); VBox vBox = new VBox(); vBox.setPadding(new Insets(5, 5, 5, 5)); vBox.setSpacing(5); vBox.getChildren().addAll(label, comboBox, btn); StackPane root = new StackPane(); root.getChildren().add(vBox); Scene scene = new Scene(root, 300, 250); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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