📄 gridbaglayoutstep1.java
字号:
import java.awt.*;public class GridBagLayoutStep1{ public static void main(String argv[]) { Frame f = new Frame("GridBagLayout Step 1"); f.setLayout(new GridBagLayout()); Button b[] = new Button[4]; int att[][] = { {0, 0, 1, 1}, {1, 0, 1, 1}, {2, 0, 1, 1}, {0, 1, 3, 1} }; for (int i=0; i<b.length; i++) { b[i] = new Button("Button "+(i+1)); add(f, b[i], att[i]); } f.pack(); f.setVisible(true); } private static void add(Container con, Component com, int att[]) { GridBagConstraints cons = new GridBagConstraints(); cons.gridx = att[0]; cons.gridy = att[1]; cons.gridwidth = att[2]; cons.gridheight = att[3]; con.add(com, cons); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -