如何设置 TreeViewer 的初始大小?

发布于 2024-09-03 16:12:47 字数 226 浏览 2 评论 0原文

我在 jface WizardPage 中使用 TreeViewer,树中的初始输入会导致 WizardPage 垂直增长,以便它可以显示树的所有值。当展开树的值之一时,垂直滚动条将按预期工作。我希望能够最初设置树的大小,以便它是固定的,并且在首次绘制 WizardPage 时已经显示滚动条,但这样做对我来说并不是特别明显 - TreeViewer 树上的 setSize 方法不会似乎什么也没做。

任何帮助将不胜感激!

I'm using a TreeViewer within a jface WizardPage and the initial input into the tree causes the WizardPage to grow vertically so that it can show all of the tree's values. When expanding one of the tree's values, then the vertical scrollbar works as expected. I'd like to be able to set the tree's size initially so that it is fixed and the scrollbar is already shown when the WizardPage is first drawn, but doing this isn't particularly obvious to me - the setSize method on the TreeViewer's Tree doesn't seem to do anything.

Any help would be appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

少女的英雄梦 2024-09-10 16:12:47

只是为了这个老问题的记录:

我们通过使用自己的布局管理器来解决应用程序中的这个问题,我们可以为某些控件设置固定大小(在 Swing 中,我们通过使用 component.setPreferredSize(size)< /代码>)。如果没有使用这样的固定大小,我们将在执行布局时计算控件的首选大小。当用户调整应用程序窗口或对话框的大小时,这可以防止控件根据控件的内容获得越来越多的空间。

Just for the records for this old question:

We solve this problem in our applications by using an own layout manager which we can set fixed sizes for certain controls (with Swing we had done that by using component.setPreferredSize(size)). If no such fixed size is used, we calculate the preferred size of the control while performing the layout. This prevents making controls getting more and more space depending on the control's content when the user resizes the application window or dialog.

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