📄 gridlayoutdemo.java
字号:
package chapter6.layout;
import java.awt.*;
import javax.swing.*;
public class GridLayoutDemo extends JFrame {
public GridLayoutDemo() {
Container contentPane = this.getContentPane();
contentPane.setLayout(new GridLayout(2, 3, 5, 10));
contentPane.add(new JButton("one"));
contentPane.add(new JButton("two"));
contentPane.add(new JButton("three"));
contentPane.add(new JButton("four"));
contentPane.add(new JButton("five"));
contentPane.add(new JButton("six"));
this.setTitle("GridLayoutDemo");
this.setSize(400, 100);
this.setLocation(400, 400);
this.setVisible(true);
}
public static void main(String[] args) {
GridLayoutDemo test = new GridLayoutDemo();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -