作者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
推 LPH66:就把那兩個Layout給add進外面的2x1的Grid中就行啦 06/24 20:41
※ 編輯: jimhu 來自: 220.135.230.54 (06/24 20:52)
→ jimhu:當然 一定是錯的 因為我不太懂樓上的意思 SORRY= = 06/24 20:53
→ tkcn:裡面那層先放 JPanel,再對 panel 設定 layout 06/24 21:33