import javax.swing.JOptionPane;

public class windowss
{
public static void main(String[] args)
{
String aa;
aa=JOptionPane.showInputDialog("please enter a number:");
String bb;
bb=JOptionPane.showInputDialog("plese enter a number:");
int a;
a=Integer.parseInt(aa)+Integer.parseInt(bb);;
String outstr;
JOptionPane.showMessageDialog(null,"the result is:"+a,"try",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}parseInt(str),把一個字符串轉化成int類型
showInputDialog( String),一個輸入對話框
showMessageDialog(String);一個顯示消息的對話框

