目前,我有這個代碼,我有工作:使用的BoxLayout來調整JPanels在GUI
this.getContentPane().add(wwjPanel, BorderLayout.EAST);
if (includeLayerPanel)
{
this.controlPanel = new JPanel();
controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.Y_AXIS));
this.layerPanel = new LayerPanel(this.getWwd());
this.controlPanel.add(new FlatWorldPanel(this.getWwd()),Box.createRigidArea(new Dimension(1000, 1000))); //This is the top pan
this.controlPanel.add(this.getStates(), Box.createRigidArea(new Dimension(0, 100)));
this.controlPanel.add(this.getPanelAlerts(), Box.createRigidArea(new Dimension(0,100)));
this.getContentPane().add(this.controlPanel, BorderLayout.WEST);//This is the whole panel on the left
}
我試圖調整JPanels,叫做ControlPanel控制在這裏,每一個都有自己獨特的大小在我的GUI。我是用java構建GUI的新手,並且我擁有的大部分代碼都是從另一個文件中提取的。我試圖加入的代碼是這些新面板,如我的代碼中所述,並嘗試調整它們的大小。 BoxLayout是我想用來獲得我想要的效果嗎?另外,當我使用createRigidArea它似乎工作,但如果我繼續改變你傳遞給它的x和y值,似乎沒有任何事情發生。我的意思是,我沒有看到任何視覺差異通過更改值,我已經使用值範圍從0-1000。
謝謝。
這是有道理的,我在你鏈接到的文檔中看到。但是,從你的觀點來看,它已經清除了。 – MuffinMan1042