Created
January 30, 2014 07:45
-
-
Save resarahadian/8704226 to your computer and use it in GitHub Desktop.
JComboBox didalam JOptionPane
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
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