本文整理汇总了Java中charvax.swing.JComboBox类的典型用法代码示例。如果您正苦于以下问题:Java JComboBox类的具体用法?Java JComboBox怎么用?Java JComboBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JComboBox类属于charvax.swing包,在下文中一共展示了JComboBox类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ComboBoxPanel
import charvax.swing.JComboBox; //导入依赖的package包/类
ComboBoxPanel() {
setLayout(new BorderLayout());
setBorder(new TitledBorder("JComboBox"));
add(new JLabel("Press ENTER to pop up the JComboBox"),
BorderLayout.NORTH);
String[] colors = {"Red", "Blue", "Green",
"Magenta", "Mauve", "Orange", "Black",
"White", "Brown"};
_comboBox = new JComboBox(colors);
_comboBox.setMaximumRowCount(5);
_comboBox.addItemListener(this);
add(_comboBox, BorderLayout.CENTER);
JPanel southpan = new JPanel();
southpan.add(new JLabel(" Selected item is: "));
_comboBoxSelection = new JTextField(15);
_comboBoxSelection.setEnabled(false);
_comboBoxSelection.setText((String) _comboBox.getSelectedItem());
southpan.add(_comboBoxSelection);
add(southpan, BorderLayout.SOUTH);
}