import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class FirstGridLayout {
public static void main(String[] args) {
Frame windows=new Frame("表格布局");
Button btn1=new Button("1");
Button btn2=new Button("2");
Button btn3=new Button("3");
Button btn4=new Button("4");
Button btn5=new Button("5");
Button btn6=new Button("6");
windows.setLayout(new GridLayout(2,3));
windows.setVisible(true);
windows.setBounds(200,200,350,350);
windows.setBackground(Color.blue);
windows.add(btn1);
windows.add(btn2);
windows.add(btn3);
windows.add(btn4);
windows.add(btn5);
windows.add(btn6);
windows.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
//表格布局
最新推荐文章于 2024-09-09 14:40:58 发布