可以编译 但运行的时候就不行了
import javax.swing.*;
import java.awt.GridLayout;
@SuppressWarnings("serial")
class AFrame extends JFrame {
GridLayout gridLayout;
JButton a[]=new JButton[15];
AFrame(String s){
super(s);
setSize(500,300);
setLocationRelativeTo(null);
JPanel contentPane=new JPanel();
setContentPane(contentPane);
gridLayout=new GridLayout(3,5);
contentPane.setLayout(gridLayout);
for (int i=0;i<9;i++){
a[i]=new JButton(i+"");
}
a[9]=new JButton("加上"+"");
a[10]=new JButton("减去"+"");
a[11]=new JButton("乘以"+"");
a[12]=new JButton("除以"+"");
a[13]=new JButton("="+"");
a[14]=new JButton("无"+"");
for (int j=0;j<15;j++){
contentPane.add(a[j]);
}
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
}
}
public class Jisuanqi {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
AFrame frm=new AFrame("计算器");
}
}