代码如下,大家帮我看一下,谢谢了~~
import java.awt.*;
import java.awt.event.*;
public class abc {
public static void main(String[] args) {
MyForm w = new MyForm("abc");
}
}
class MyForm extends Frame {
public MyForm(String s) {
super ( s );
setLayout(null); //采用空布局
addWindowListener(new WindowAdapter() { //退出
public void windowClosing(WindowEvent e) {
dispose();
System.exit(0);
}
});
this.setBounds(300, 200, 260, 260); //设置宽高
setVisible(true); //设置可见
int n = 5;
Button[] button = new Button[n * n];
Panel panel = new Panel();
panel.setLayout(new GridLayout(n, n));
panel.setBounds(10, 50, 150, 150);
add(panel);
for (int i = 0; i < button.length; i++) {
button[i] = new Button(""+i);
panel.add(button[i]);
}
}
}