import javax.swing.*;
import java.util.*;
import java.awt.*;
class GridLayoutFrame extends JFrame{
JLabel label1 = new JLabel(" 星期日 ",JLabel.CENTER);
JLabel label2 = new JLabel(" 星期一 ",JLabel.CENTER);
JLabel label3 = new JLabel(" 星期二 ",JLabel.CENTER);
JLabel label4 = new JLabel(" 星期三 ",JLabel.CENTER);
JLabel label5 = new JLabel(" 星期四 ",JLabel.CENTER);
JLabel label6 = new JLabel(" 星期五 ",JLabel.CENTER);
JLabel label7 = new JLabel(" 星期六 ",JLabel.CENTER);
String strArr[] = {"1","2","3","4","5","6","7",
"8","9","10","11","12","13","14",
"15","16","17","18","19","20","21",
"22","23","24","25","26","27","28",
"29","30","31","","",""};
JButton btnArr[];
GridLayoutFrame(){
setTitle("网格布局显示器");
setSize(750,550);
setLocation(300,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel p = new JPanel();
p.add(label1);
p.add(label2);
p.add(label3);
p.add(label4);
p.add(label5);
p.add(label6);
p.add(label7);
p.setLayout(new GridLayout(6,7,5,10));
btnArr = new JButton[35];
for(int i = 0;i<strArr.length;i++){
btnArr[i] = new JButton(strArr[i]);
p.add(btnArr[i]);
}
setContentPane(p);
}
}
class main{
public static void main(String[] args){
GridLayoutFrame g = new GridLayoutFrame();
g.setVisible(true);
}
//SetFontFrame
}