Skip to content

Instantly share code, notes, and snippets.

@resarahadian
Created January 30, 2014 07:45
Show Gist options
  • Save resarahadian/8704226 to your computer and use it in GitHub Desktop.
Save resarahadian/8704226 to your computer and use it in GitHub Desktop.
JComboBox didalam JOptionPane
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
public class ClComboOptionPane
{
static String question(String[] pilih)
{
String str = (String) JOptionPane.showInputDialog(
null,
"Daftar Menu",
"ComboBox didalam JOptionPane",
JOptionPane.QUESTION_MESSAGE,
null,
pilih,
pilih[0]);
return str;
}
public static void main(String[] args)
{
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
} catch (ClassNotFoundException | InstantiationException
| IllegalAccessException | UnsupportedLookAndFeelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String[] pilihan = new String[]{"=== Silahkan Pilih ===","Nasi Goreng", "Mie Goreng", "Es Teh Manis", "Susu Coklat"};
String pilih = question(pilihan);
JOptionPane.showMessageDialog(null, "Anda Memesan : " + pilih, "Pesan", JOptionPane.INFORMATION_MESSAGE, new ImageIcon("src/comboOptionPane/option.png"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment