0
我想建立如下的佈局使用具有JInternalFrames的所有可用空間:在GridBagLayout的
+--------------+-------+
| | |
| | O |
| GAME | P |
| | T |
| | |
+--------------+-------+
| |
| CONDITIONS |
| |
+--------------+-------+
而每個組件應該是一個框架
我決定使用GridBagLayout
和它種工作方式:
的問題是相當明顯的:這些幀的方式向小
這裏的詞典定義。他示例代碼的框架之一(它們幾乎都是一樣的):正如你看到的,他們什麼都不做還
public class Game extends JInternalFrame {
public Game(){
super("Game");
}
}
這裏是我如何構建佈局:
//set dimension (x, y)
this.setSize(900, 600);
//deny resizing
this.setResizable(false);
//set position (x: top, y: left)
this.setLocation(300, 300);
[....]
this.options = new Options();
this.conditions = new Conditions();
this.game = new Game();
this.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.VERTICAL;
c.gridx = 1;
c.gridy = 0;
this.add(this.options, c);
c.fill = GridBagConstraints.BOTH;
c.gridx = 0;
c.gridy = 0;
this.add(this.game, c);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy = 1;
c.gridwidth = 2;
this.add(this.conditions, c);
this.options.setVisible(true);
this.conditions.setVisible(true);
this.game.setVisible(true);
所以我問題是
1)我如何獲得幀使用的窗口 2)的全部空間如何使他們在不同勢大小(如this.options.setSize(...)
不工作?)
PS:這裏是全碼:http://pastebin.com/TSWyyi7v
'下面是完整的代碼:HTTP:// pastebin.com/TSWyyi7v' - 我毫無疑問,這不是這個網站的工作方式,爲了更快地發佈一個[SSCCE](http://sscce.org/),更好的幫助,簡短,可運行,可編譯,幾乎只有一個JInternalFrame和GBC問題, [您的SSCCE可以基於我的一個帖子](http://stackoverflow.com/a/20114198/714968) – mKorbel
@mKorbel你是對的這不是完整的代碼,但它是Windows完整的代碼(忘了寫那) –
無論如何這裏是一個可編譯和可執行縮小的例子http://pastebin.c om/sZqu8q56(已經有所改進) –