GUi组件篇1

来源:互联网 发布:三星i9300软件下载 编辑:程序博客网 时间:2024/06/02 02:06

1.JOptionPane

输入输出,

import javax.swing.JOptionPane;
public class Addtion {
public static void main(String[] args) {
// TODO Auto-generated method stub

String a=JOptionPane.showInputDialog("enter first num");
String b=JOptionPane.showInputDialog("enter secnod num");
int one=Integer.pa
rseInt(a);//将a中的字符串转化int类型;

int two=Integer.parseInt(b);
int sum=one+two;
JOptionPane.showMessageDialog(null, "the sum is: "+sum, "sum of two integ", JOptionPane.PLAIN_MESSAGE);//四个参数 第一个是确定在哪显示,null表示显示在屏幕
中间,第二个参数为显示的消息,3标题栏,4显示消息对话的类型,此处表示文字左边没有图片。

}


}

0 0