Skip to content

Instantly share code, notes, and snippets.

@arbo77
Created August 10, 2012 23:52
Show Gist options
  • Save arbo77/3319063 to your computer and use it in GitHub Desktop.
Save arbo77/3319063 to your computer and use it in GitHub Desktop.
Step by step simple Java GUI example (ComboBox & ListBox)
....
private DefaultComboBoxModel ganjil = new DefaultComboBoxModel();
private JComboBox cmb = new JComboBox(ganjil);
private DefaultListModel genap = new DefaultListModel();
private JList list = new JList(genap);
....
....
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