Java:jsplitpane 和 boxlayout 的问题
我想摆脱 jsplitpanes 左侧的空白区域:
这是我的代码:
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitPane.add(downloadsPanel);
splitPane.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);
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);
splitPane.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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
BoxLayout 在组件对齐方面做了一些奇怪的事情。阅读 swing 教程中有关修复对齐问题的部分。简而言之,确保 addPanel 和 splitPane3 的对齐方式相同:
在我看来,一个默认为 CENTER,另一个默认为 LEFT。
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:
It looks to me like one defaults to CENTER and the other defaults to LEFT.