import java.awt.Button;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Panel;
import java.awt.TextField;
public class Xi{
public static void main(String[] args) {
Frame a=new Frame("计算机");
//创建窗体
Panel b=new Panel();
//创建panel容器
b.add(new TextField(20));
//向panel容器加组件
a.add(b,"North");
//往Frame窗体默认的BorderLayout加组件
Panel c=new Panel();
c.setLayout(new GridLayout(3,5,4,4));
//使用setLayout布局管理器
String[] mm={"0","1","2","3","4","5","6",
"7", "8","9","+","-","*","/","="};
for (String string : mm) {
c.add(new Button(string));
}
a.add(c);
//向Frame窗体加Panel对象
a.pack();
//设置窗体最佳大小
a.setVisible(true);
//窗体显示出来
}
}
有不明白的地方,可以问亚瑟宝宝哦。