gridlayoutdemo.txt

来自「JAVA的一些基础教程」· 文本 代码 · 共 30 行

TXT
30
字号
1: import java.awt.*;
2: import java.awt.event.*;
3: 
4: public class GridLayoutDemo {
5:   public GridLayoutDemo() {
6:     Frame frame = new Frame("gridLayoutDemo");
7:     frame.setLayout(new GridLayout(3, 2));
8:     frame.add(new Button("one"));
9:     frame.add(new Button("two"));
10:     frame.add(new Button("three"));
11:     frame.add(new Button("four"));
12:     frame.add(new Button("five"));
13:     frame.add(new Button("six"));
14:     frame.pack();
15:     frame.setVisible(true);
16: 
17:     frame.addWindowListener(new WindowAdapter() {
18:       public void windowClosing(WindowEvent e) {
19:         System.exit(0);
20:       }
21:     }
22:     );
23:   }
24: 
25:   public static void main(String args[]) {
26:     GridLayoutDemo demo = new GridLayoutDemo();
27:   }
28: 
29: }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?