📄 gridtest.java
字号:
import java.awt.*;
import javax.swing.*;
public class GridTest extends JFrame {
public static void main(String[] args) {
if (args.length < 2) {
System.out.println("You must enter a row count and a column count");
return;
}
int rows = Integer.parseInt(args[0]);
int cols = Integer.parseInt(args[1]);
GridTest gt = new GridTest(rows, cols);
gt.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
gt.pack();
gt.setVisible(true);
}
public GridTest(int rows, int cols) {
Container pane = getContentPane();
pane.setLayout(new GridLayout(rows, cols));
for (int i = 0; i < 20; i++) {
JButton button = new JButton(Integer.toString(i + 1));
pane.add(button);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -