Created
August 10, 2012 23:52
-
-
Save arbo77/3319063 to your computer and use it in GitHub Desktop.
Step by step simple Java GUI example (ComboBox & ListBox)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
private DefaultComboBoxModel ganjil = new DefaultComboBoxModel(); | |
private JComboBox cmb = new JComboBox(ganjil); | |
private DefaultListModel genap = new DefaultListModel(); | |
private JList list = new JList(genap); | |
.... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
private void btnTambahClick(ActionEvent evt){ | |
Integer p; | |
try | |
{ | |
p = Integer.parseInt(tBil.getText()); | |
if (p % 2 == 0) | |
{ | |
genap.insertElementAt(p.toString(),0); | |
}else{ | |
ganjil.insertElementAt(p.toString(),0); | |
} | |
} | |
catch (Exception e) | |
{ | |
System.out.println(e); | |
JOptionPane.showMessageDialog(null, | |
e.toString(), | |
"Error", | |
JOptionPane.ERROR_MESSAGE); | |
} | |
} | |
.... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment