We have troubles with the ListView of a Combobox, when trying to avoid showing the Scrollbar.
Following sample illustrates the problem:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class ComboBoxSample extends Application {
@Override public void start(Stage stage) {
final ComboBox testComboBoxOK = new ComboBox();
String values[] = {"1","2","3","4","5","6","7","8","9","10","11","12"};
testComboBoxOK.getItems().addAll(values);
testComboBoxOK.setVisibleRowCount(values.length);
final ComboBox testComboBoxWrong = new ComboBox();
testComboBoxWrong.getItems().addAll(values);
testComboBoxWrong.getItems().add("13");
testComboBoxWrong.setVisibleRowCount(values.length + 1);
HBox horizontalBox = new HBox();
horizontalBox.setSpacing(10.0);
horizontalBox.getChildren().addAll(testComboBoxOK, testComboBoxWrong);
Scene scene = new Scene(horizontalBox, 450, 250);
stage.setScene(scene);
stage.show();
}
}
When using a stylesheet like the one below it gets worse:
.combo-box-popup .list-cell{
-fx-text-fill: blue;
-fx-background-color: yellow;
-fx-border-color: red;
-fx-border-width: 10 10 0 10;
}
Following sample illustrates the problem:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class ComboBoxSample extends Application {
@Override public void start(Stage stage) {
final ComboBox testComboBoxOK = new ComboBox();
String values[] = {"1","2","3","4","5","6","7","8","9","10","11","12"};
testComboBoxOK.getItems().addAll(values);
testComboBoxOK.setVisibleRowCount(values.length);
final ComboBox testComboBoxWrong = new ComboBox();
testComboBoxWrong.getItems().addAll(values);
testComboBoxWrong.getItems().add("13");
testComboBoxWrong.setVisibleRowCount(values.length + 1);
HBox horizontalBox = new HBox();
horizontalBox.setSpacing(10.0);
horizontalBox.getChildren().addAll(testComboBoxOK, testComboBoxWrong);
Scene scene = new Scene(horizontalBox, 450, 250);
stage.setScene(scene);
stage.show();
}
}
When using a stylesheet like the one below it gets worse:
.combo-box-popup .list-cell{
-fx-text-fill: blue;
-fx-background-color: yellow;
-fx-border-color: red;
-fx-border-width: 10 10 0 10;
}