返回本章节
返回作业目录
需求说明:
将JButton按钮按网格布局管理器格式放置
实现思路:
实现代码:
public void init(){
setLayout(new GridLayout(4, 4));
setFont(new Font("Times New Roman", Font.BOLD, 24));
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
int k=i*4+j;
add(new JButton(""+k));
}
}
this.setSize(450,300);
this.setVisible(true);
}