import java.awt.*;
import javax.swing.*;
public class Calculater {
public static void main(String[] args) {
JFrame f = new JFrame("简易计算器");
f.setSize(440,500);
f.setLocation(500, 200);
f.setResizable(false);
JPanel p=new JPanel(null);
p.setBounds(20,60,400, 400);
p.setLayout(new GridLayout(4, 4));
String[] name={
"7","8","9","*","4","5","6","-","1","2","3","+","/","0",".","="};
for(int i=0;i<name.length;i++){
JButton b=new JButton(name[i]);
b.setSize(50, 50);
p.add(b);
}
JTextField text=new JTextField("0");
text.setBounds(20, 10, 400, 50);
text.setBackground(Color.pink);
text.setHorizontalAlignment(JTextField.RIGHT);
f.setLayout(null);
f.add(p);
f.add(text);
f.setVisible(true);
}
}