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));
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.
精彩评论