作者jimhu (胡小扬)
看板java
标题[问题] BorderLayout on GridLayout
时间Thu Jun 24 20:28:26 2010
想要做一个程式如下
1
2 3 4
5
6 7
8 9
10 11
12 13
每个数字都是一个Button
而且在拉视窗的时候 上面的GridLayout 下面的BorderLayout会一起变大变小
也就是Frame是一个2X1的Grid
然後在Frame第一列内放入BorderLayout
第二列放入GridLayout这样
但想不出来 程式码要怎麽写 才能把Border放在底下的Grid里面
有人能解答吗~?
补充:
我想出来的程式码= =
import java.awt.*;
import java.awt.event.*;
public class GridLayoutDemo extends java.awt.Frame {
public static void main(String args[]){
new GridLayoutDemo();
}
public GridLayoutDemo() {
super("Grid Layout Demo");
final int row = 2;
final int column = 1;
setLayout(new GridLayout(row, column));
Button button1 = new Button("EAST");
Button button2 = new Button("SOUTH");
Button button3 = new Button("WEST");
Button button4 = new Button("NORTH");
Button button5 = new Button("CENTER");
this.setSize(480, 720);
this.setVisible(true);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.135.230.54
1F:推 LPH66:就把那两个Layout给add进外面的2x1的Grid中就行啦 06/24 20:41
※ 编辑: jimhu 来自: 220.135.230.54 (06/24 20:52)
2F:→ jimhu:当然 一定是错的 因为我不太懂楼上的意思 SORRY= = 06/24 20:53
3F:→ tkcn:里面那层先放 JPanel,再对 panel 设定 layout 06/24 21:33