[英]java jcombobox without scrollbar?
我有一个JComboBox组件:
ho2Combo = new JComboBox();
ho2Combo.setLocation(x, y);
ho2Combo.setSize(w, h);
ho2Combo.setFont(comboFont);
ho2Combo.setModel(new DefaultComboBoxModel(Format.model(0))); //this fills up the combobox
ho2Combo.setSelectedIndex(0);
ho2Combo.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent evt) {
ho2ComboItemStateChanged(evt);
}
});
add(ho2Combo);
我希望这个组合框没有滚动条! 我怎么能做到这一点? 请帮忙! 谢谢!
如果您确信所有元素都适合屏幕显示,则可以使用:
ho2Combo.setMaximumRowCount(ho2Combo.getModel().getSize());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.