在 JSplitPane 内调整 JToolbar 大小
我正在尝试创建一个应用程序,其中有一个 JSplitPane,其中包含左侧的文档树和右侧的当前编辑器窗格。 编辑器窗格有一个工具栏作为编辑窗格的一部分。 我的问题是,当拆分窗格的右侧组件达到工具栏的大小时,调整包含 JSplitPane 的 JFrame 的大小时,右窗格开始“挤压”左窗格。
我想知道是否有人知道一种方法,可以使分割面板的两个组件保持相同的比例,并让工具栏停止显示其中的项目,或者有一个“更多”按钮。 我在框架工具栏中有“更多”功能的底格里斯工具栏,它似乎不会在 JScrollpane 中调整大小。
谢谢您的帮助。
I'm trying to create an application where there is a JSplitPane which contains the document tree on the left side and the current editor pane on the right. The editor pane has a toolbar as part of the edit pane. My problem is that when the JFrame containing the JSplitPane is resized as soon as the right component of the split pane reaches the size of the toolbar the right pane starts to 'squish' the left pane.
I was wondering if anyone knew of a way to keep the two components of the splitpane at the same ratio and have either the toolbar to stop displaying the items within it or have a 'more' button. I've got the tigris toolbar for the 'more' capability working in the frames toolbar, it just seems that it wont resize within the JScrollpane.
Thanks for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解正确,您希望在调整父框架大小时让分割窗格以相同的优先级对待两侧。 如果是这种情况,您可能需要查看方法
JSplitPane.setResizeWeight(double)
。考虑到这一点,我会尝试 0.5。
编辑
查看BasicSplitPaneUI的代码,在调整大小时,无论重量如何,它都会考虑左右组件的最小尺寸。 请注意,重量仍然很重要。 它只是被最少的组件所击败。 考虑到这一点,尝试在工具栏或包含它的滚动窗格上设置最小尺寸。
if i understand correctly, you are looking to get the split pane to treat both sides with the same priority when the parent frame is getting resized. if that is the case, you may want to look at the method
JSplitPane.setResizeWeight(double)
.with that in mind, i would give 0.5 a try.
edit
looking at the code for the BasicSplitPaneUI, it will take the minimum size of both the left and right component into consideration when it is resizing, regardless of the the weight. the weight is still important, mind you. it is just trumped by the minimum of the components. with this in mind, try setting the minimun size on your toolbar or the scrollpane within which it is contained.