在 JSplitPane 内调整 JToolbar 大小

发布于 2024-07-27 05:33:25 字数 300 浏览 4 评论 0原文

我正在尝试创建一个应用程序,其中有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

≈。彩虹 2024-08-03 05:33:25

如果我理解正确,您希望在调整父框架大小时让分割窗格以相同的优先级对待两侧。 如果是这种情况,您可能需要查看方法 JSplitPane.setResizeWeight(double)

指定当分割窗格的大小发生变化时如何分配额外空间。 默认值 0 表示右/底部组件获得所有额外空间(左/顶部组件固定),而值为 1 则指定左/顶部组件获得所有额外空间(右/顶部组件固定)。底部组件固定)。 具体来说,左侧/顶部组件获得 (weight * diff) 额外空间,右侧/底部组件获得 (1 - Weight) * diff 额外空间。

考虑到这一点,我会尝试 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).

Specifies how to distribute extra space when the size of the split pane changes. A value of 0, the default, indicates the right/bottom component gets all the extra space (the left/top component acts fixed), where as a value of 1 specifies the left/top component gets all the extra space (the right/bottom component acts fixed). Specifically, the left/top component gets (weight * diff) extra space and the right/bottom component gets (1 - weight) * diff extra space.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文