我beeginer在MigLayout所以,我需要補充的倍數JTable中的一個的JPanel,但是當我嘗試添加多個表,似乎剛剛過去的表,和其他人只是標JScrollPane邊界。我的代碼在下面。多JTable中使用Miglayout
Test() {
//Panels
JPanel globalPanel = new JPanel(new MigLayout("fillx","[]","[]50[]"));
JPanel topPanel = new JPanel (new MigLayout("fillx","40px[]15[grow]","40px[]"));
JPanel tablePanel = new JPanel (new MigLayout("fillx","[center]","[]"));
//Components
JComboBox boxProj;
JTable table;
JScrollPane scroll;
//Top Panel
topPanel.add(new JLabel("Project Name:"));
String listString[] = {"test"};
boxProj= new JComboBox(listString);
topPanel.add(boxProj);
//Table Panel
//Tables
table = new JTable();
createTable(table); //my table
//Adding Multiples Tables
tablePanel.add(new JScrollPane(table),"growx,wrap,hmax 300");
tablePanel.add(new JScrollPane(table),"growx,wrap,hmax 300");
//Scroll to TablePanel
scroll = new JScrollPane(tablePanel);
scroll.setBorder(BorderFactory.createTitledBorder(null, "Project", TitledBorder.LEFT, TitledBorder.TOP, new Font("null", Font.BOLD, 12), Color.BLACK));
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
//Global Panel
globalPanel.add(topPanel, "dock north");
JSeparator separator = new JSeparator();
globalPanel.add(separator,"growx");
globalPanel.add(scroll,"dock south, growx");
getContentPane().add(globalPanel);
pack();
setSize(1024,768);
}
如果我犯了一些錯誤,請糾正我。
謝謝!
不要忘了[接受一個答案(http://meta.stackexchange.com/a/65088/155831)。它有助於未來的讀者:) – Reimeus 2013-03-14 14:44:43
我仍然沒有狀態,以驗證答案。 「投票最多需要15聲譽」,我只有11 – Andriel 2013-03-14 14:49:39
+1來提高你的代表有點:) – Reimeus 2013-03-14 14:53:13