public ComboBoxFrame()
{
super("Testing JComboBox");
setLayout(new FlowLayout()); // set frame layout
imagesJComboBox = new JComboBox<String>(names); // set up JComboBox
imagesJComboBox.setMaximumRowCount(3); // display three rows
add(imagesJComboBox); // add combobox to JFrame
label = new JLabel(icons[0]); // display first icon
add(label); // add label to JFrame
imagesJComboBox.addItemListener(event -> {
if (event.getStateChange() == ItemEvent.SELECTED)
label.setIcon(icons[imagesJComboBox.getSelectedIndex()]);
}); // end call to addItemListener
}
ComboBoxFrame.java 文件源码
java
阅读 36
收藏 0
点赞 0
评论 0
项目:LivroJavaComoProgramar10Edicao
作者:
评论列表
文章目录