Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #19831 > unrolled thread
| Started by | Rotariu Mihai <rotariu.mihai7@gmail.com> |
|---|---|
| First post | 2012-11-21 00:58 -0800 |
| Last post | 2012-11-21 01:06 -0800 |
| Articles | 2 — 1 participant |
Back to article view | Back to comp.lang.java.programmer
JComboBox model doesn't allow to add or remove Rotariu Mihai <rotariu.mihai7@gmail.com> - 2012-11-21 00:58 -0800
Re: JComboBox model doesn't allow to add or remove Rotariu Mihai <rotariu.mihai7@gmail.com> - 2012-11-21 01:06 -0800
| From | Rotariu Mihai <rotariu.mihai7@gmail.com> |
|---|---|
| Date | 2012-11-21 00:58 -0800 |
| Subject | JComboBox model doesn't allow to add or remove |
| Message-ID | <14c15e6e-6d2e-4555-811e-47ca3a7532f9@googlegroups.com> |
public void keyPressed(KeyEvent e) {
String ip = (String) jComboBox1.getEditor().getItem();
int key = e.getKeyCode();
if (key == KeyEvent.VK_ENTER) {
if (ip == null || ip.trim().isEmpty()) {
jComboBox1.setSelectedItem("Please insert a keyword!");
} else {
if (jRadioButton1.isSelected()) {
model.removeAllElements();
}
}
}
}
[toc] | [next] | [standalone]
| From | Rotariu Mihai <rotariu.mihai7@gmail.com> |
|---|---|
| Date | 2012-11-21 01:06 -0800 |
| Message-ID | <86e441e1-ec2a-46c4-8116-2435f3778bf9@googlegroups.com> |
| In reply to | #19831 |
DefaultComboBoxModel model = new DefaultComboBoxModel(); jComboBox1 = new javax.swing.JComboBox(model); jComboBox1.setModel(model); This is how I set the model for the jComboBox. Can you please take a look and let me know why is not working? Thanks
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web