本文整理匯總了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);
}