import javax.swing.JOptionPane;
public class InputBilangan {
public static void main (String [] args) {
int bil1,bil2,jum;
String srt=JOptionPane.showInputDialog("Masukkan bilangan1 : ");
bil1=Integer.parseInt(srt);
String srt1=JOptionPane.showInputDialog("Masukkan bilangan2 : ");
bil2=Integer.parseInt(srt1);
jum=bil1+bil2;
JOptionPane.showMessageDialog(null, "Bilangan "+bil1+ "+"+"Bilangan "
+bil2+" ="+jum,"Hasil Penjumlahan",
JOptionPane.INFORMATION_MESSAGE);
}}
Penjelasan diambil dari :
http://download.oracle.com/javase/1.5.0/docs/api/javax/swing/JOptionPane.html
Method Name | Description |
showConfirmDialog | Asks a confirming question, like yes/no/cancel. |
showInputDialog | Prompt for some input. |
showMessageDialog | Tell the user about something that has happened. |
showOptionDialog | The Grand Unification of the above three. |