setVisibleRowCount does not work if called before filling of items list. The resulted height of drop-down length is much less then it should be.
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage stage) {
VBox content = new VBox();
final ComboBox cb = new ComboBox();
cb.setEditable(true);
stage.setScene(new Scene(content, 400, 400));
Button btn = new Button("Reset");
btn.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
cb.setVisibleRowCount(4);
for (int i = 0; i < 10; i++) {
cb.getItems().addAll(String.valueOf(i));
}
}
});
content.getChildren().addAll(cb, btn);
stage.show();
}
public static void main(String[] args) {
launch(Main.class, args);
}
}
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage stage) {
VBox content = new VBox();
final ComboBox cb = new ComboBox();
cb.setEditable(true);
stage.setScene(new Scene(content, 400, 400));
Button btn = new Button("Reset");
btn.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
cb.setVisibleRowCount(4);
for (int i = 0; i < 10; i++) {
cb.getItems().addAll(String.valueOf(i));
}
}
});
content.getChildren().addAll(cb, btn);
stage.show();
}
public static void main(String[] args) {
launch(Main.class, args);
}
}
- duplicates
-
JDK-8088059 [ComboBox] when visible row count is set, popup height doesn't change
-
- Open
-
-
JDK-8126063 [EditableComboBox] in editable comboBox size of popup doesn't respond to the visible amount.
-
- Closed
-
-
JDK-8127288 [ComboBox] list in popup too little
-
- Closed
-