import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import java.awt.BorderLayout;
class Calculator extends JFrame{
private JPanel pan= new JPanel();
private JButton button;
private JTextField text;
String number[]={"7","8","9","/","4","5","6","*","1","2","3","-","0",".","=","+"};
public Calculator() {
super("小神童计算器");
setSize(600,600);
setLayout(new BorderLayout(5,5));
setVisible(true);
text=new JTextField("请输入数字",20);
pan.setLayout(new GridLayout(4,4));
for(int i=0;i<12;i++){
button=new JButton(number[i]);
pan.add(button);
}
pan.setVisible(true);
//add(text,BorderLayout.NORTH);
add(pan,BorderLayout.CENTER);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
public class test {
public static void main(String [] args){
Calculator cal=new Calculator();
}
}
慕码人8056858
繁星淼淼
相关分类