I am trying to implement an ActionListener for a JComboBoxe so that when an item in the list is selected, and the ok jbutton clicked, I want it to appear in a new gui I have defined with a textfield in it therefore when an item is selected从组合框中,它将出现在 gui 的文本字段中,并显示所选项目的详细信息。
这个例子显示了一个组合框,但我总共有 6 个。
jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jComboBox4.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jComboBox4MouseClicked(evt);
}
});