开发者

Java: Issue with jsplitpane and boxlayout

I want to get rid of the empty space to the left of the jsplitpanes:

Java: Issue with jsplitpane and boxlayout

Here's my code:

getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitPane.add(downloadsPanel);
spli开发者_如何学PythontPane.add(filesPanel);

JSplitPane splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitPane2.add(processingPanel);
splitPane2.add(messagePanel);

JSplitPane splitPane3 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);

splitPane3.add(splitPane);
splitPane3.add(splitPane2);

getContentPane().add(addPanel);
getContentPane().add(splitPane3);


BoxLayout does weird things with the alignment of components. Read the section from the swing tutorial on Fixing Alignment Problems. In short, make sure the alignment of the addPanel and splitPane3 are the same:

component.setAlignmentX(Component.CENTER_ALIGNMENT);

It looks to me like one defaults to CENTER and the other defaults to LEFT.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜