本文整理汇总了Java中javax.swing.JComboBox.setEditor方法的典型用法代码示例。如果您正苦于以下问题:Java JComboBox.setEditor方法的具体用法?Java JComboBox.setEditor怎么用?Java JComboBox.setEditor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComboBox
的用法示例。
在下文中一共展示了JComboBox.setEditor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPreferredSize
import javax.swing.JComboBox; //导入方法依赖的package包/类
public Dimension getPreferredSize() {
Dimension dim = super.getPreferredSize();
if (PREFERRED_HEIGHT == -1) {
GenericToolbar tb = new GenericToolbar();
tb.setBorder(getBorder());
tb.setBorderPainted(isBorderPainted());
tb.setRollover(isRollover());
tb.setFloatable(isFloatable());
Icon icon = Icons.getIcon(GeneralIcons.SAVE);
tb.add(new JButton("Button", icon)); // NOI18N
tb.add(new JToggleButton("Button", icon)); // NOI18N
tb.add(new JTextField("Text")); // NOI18N
JComboBox c = new JComboBox();
c.setEditor(new BasicComboBoxEditor());
c.setRenderer(new BasicComboBoxRenderer());
tb.add(c);
tb.addSeparator();
PREFERRED_HEIGHT = tb.getSuperPreferredSize().height;
}
dim.height = getParent() instanceof JToolBar ? 1 :
Math.max(dim.height, PREFERRED_HEIGHT);
return dim;
}
示例2: init
import javax.swing.JComboBox; //导入方法依赖的package包/类
/** Creates a new instance of ColorChooser */
static void init (final JComboBox<ColorValue> combo) {
combo.setModel (new DefaultComboBoxModel<> (content));
combo.setRenderer (new ColorComboBoxRenderer (combo));
combo.setEditable (true);
combo.setEditor (new ColorComboBoxRenderer (combo));
combo.setSelectedItem (new ColorValue (null, null));
combo.addActionListener (new ComboBoxListener (combo));
}