來源自 這裡
Question:
In Swing, what's the best way to make the JSplitPane to split two jpanels with 50% size each. It looks like if I don't set preferred sizes on the panels it always makes the first panel almost invisible (2%) and the second one (98%)
Answer:
可以透過 API:setResizeWeight(weight). 該 API 的使用說明如下:
假設你已經有一個 JSplitPane 物件 jSplitPaneEdit, 則你可以如下設定該 JSplitPane 的物件透過 divider 50/50 切割左右或上下平面:
Question:
In Swing, what's the best way to make the JSplitPane to split two jpanels with 50% size each. It looks like if I don't set preferred sizes on the panels it always makes the first panel almost invisible (2%) and the second one (98%)
Answer:
可以透過 API:setResizeWeight(weight). 該 API 的使用說明如下:
假設你已經有一個 JSplitPane 物件 jSplitPaneEdit, 則你可以如下設定該 JSplitPane 的物件透過 divider 50/50 切割左右或上下平面:
- jSplitPaneEdit.setDividerLocation(-1);
- jSplitPaneEdit.setResizeWeight(0.5);
- jSplitPaneEdit.repaint();
This message was edited 1 time. Last update was at 13/01/2014 16:44:07
沒有留言:
張貼留言