开发者

Java: Issue with jsplitpane and boxlayout

开发者 https://www.devze.com 2023-03-13 23:52 出处:网络
I want to get rid of the empty space to the left of the jsplitpanes: Here\'s my code: getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

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

精彩评论

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