![](/img/trans.png)
[英]JavaFX Wombo Combo-displaying the text depending on the choice from the drop-down list
[英]JavaFx Combobox drop down list width is less on first click on Combo box
當我第一次點擊ComboBox時,顯示的彈出菜單列表的寬度非常短。 第二次單擊ComboBox並再次顯示列表時,寬度現在正確,因為列表的寬度現在與Combbox對齊。
我試圖改變鼠標單擊組合框時下拉的寬度。 但它不起作用,
final ComboBox<String> combo = new ComboBox<String>();
combo.getStyleClass().add("combo-border");
combo.setMinWidth(100.0);
combo.setEditable(true);
combo.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent arg0) {
combo.setMinWidth(100.0); // Did not work
//csectCombo.setPrefWidth(100.0); // Did not work
}
});
我正在使用Javafx 2.2。 這有什么解決方法嗎?
從下面的帖子中可以看出,這是JavaFx 2中的已知錯誤,並已在JavaFx 8中修復。
http://tech.chitgoks.com/2013/09/20/width-of-combobox-popup-list-is-too-small-in-java-fx-2/
試試這個
final ComboBox<String> combo = new ComboBox<String>();
combo.getStyleClass().add("combo-border");
combo.setMinWidth(100.0);
combo.setEditable(true);
combo.setPrefWidth(combo.getMinWidth());
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.