Vaadin - 多选项卡布局

发布于 2024-12-26 02:47:42 字数 694 浏览 2 评论 0原文

我有几个 Vaadin 选项卡,其中一个显示表格和一些按钮,另一个显示分层 Vaadin 树并具有自定义搜索框。我已将选项卡的大小设置为 H:420px W:250px,因此它们具有相同的大小,如果表格太大或树太长,我会得到一个滚动条(这就是我想要的),问题是其他组件就像搜索框和按钮被强制向下放置在布局的底部一样,所以如果我想访问按钮/搜索框,我必须一直向下滚动,这样我才能使用我想要的组件。我尝试仅为组件添加第二个布局,但没有帮助:-/这是我迄今为止尝试过的:

TabSheet tabs = new TabSheet();
tabs.setWidth("250");
tabs.setHeight("420");

VerticalLayout lyTab = new VerticalLayout();
tabOne = tabs.addTab(lyTab, "Tab One", null);
//added an extra layout for the Buttons :
HorizontalLayout  lyButton = new HorizontalLayout();
lyButton.addComponent(applyButton);
lyButton.addComponent(selectAll);
lyTab.addComponent(lyButton);

我的想法是向 tabSheet 添加第二个布局,这样我就可以修复它的位置,使其无法移动但这没有用。有什么想法吗?

I have few Vaadin tabs one of them is displaying an table and some buttons, another one displays an Hierarchical Vaadin tree and has an custom search Box. I have set the size of my tabs to H:420px W:250px so they have the same size, if the table gets too big or the tree to long I get an scrollbar (that’s what I wanted) the problem is that the other components like the search Box and the buttons are being forced down at the bottom of the layout so if I want to access the buttons/ search Box I have to scroll all the way down so I can use the component I want. I have tried to add an second layout only for the components but it didn’t help:-/ here’s what I have tried so far:

TabSheet tabs = new TabSheet();
tabs.setWidth("250");
tabs.setHeight("420");

VerticalLayout lyTab = new VerticalLayout();
tabOne = tabs.addTab(lyTab, "Tab One", null);
//added an extra layout for the Buttons :
HorizontalLayout  lyButton = new HorizontalLayout();
lyButton.addComponent(applyButton);
lyButton.addComponent(selectAll);
lyTab.addComponent(lyButton);

my idea was to add an second layout to the tabSheet so i can fix its position so it cant move but it didnt work . any ideas ?

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

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

发布评论

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

评论(2

厌倦 2025-01-02 02:47:42

如果我正确理解您的问题,这里是如何使用表格来做到这一点:

VerticalLayout tab = new VerticalLayout();
tab.setSizeFull();

Table table = new Table();
table.setSizeFull();
tab.addComponent(table);
tab.setExpandRatio(table, 1);

HorizontalLayout buttons = new HorizontalLayout();
buttons.addComponent(new Button());
buttons.addComponent(new Button());
tab.addComponent(buttons);

Tab tabOne = tabs.addTab(tab, "Tab One", null);

在这种情况下,表格是全尺寸的,并在需要时显示滚动条。

对于树,将上面代码中的表格部分替换为:

Panel panel = new Panel();
panel.setSizeFull();
panel.getContent().setSizeUndefined();
tab.addComponent(panel);
tab.setExpandRatio(panel, 1);

Tree tree = new Tree();
tree.setSizeUndefined();
panel.addComponent(tree);

这里树无法显示滚动条,因此我们将其包装在一个全尺寸的面板中,该面板在需要时显示滚动条。

If I understand your problem correctly here is how to do it with a Table:

VerticalLayout tab = new VerticalLayout();
tab.setSizeFull();

Table table = new Table();
table.setSizeFull();
tab.addComponent(table);
tab.setExpandRatio(table, 1);

HorizontalLayout buttons = new HorizontalLayout();
buttons.addComponent(new Button());
buttons.addComponent(new Button());
tab.addComponent(buttons);

Tab tabOne = tabs.addTab(tab, "Tab One", null);

In this case, the Table is full sized and shows scrollbars when needed.

For a Tree, replace the Table part from above code with:

Panel panel = new Panel();
panel.setSizeFull();
panel.getContent().setSizeUndefined();
tab.addComponent(panel);
tab.setExpandRatio(panel, 1);

Tree tree = new Tree();
tree.setSizeUndefined();
panel.addComponent(tree);

Here the Tree is not able to show scrollbars so we wrap it inside a full sized Panel that shows scrollbars when needed.

肥爪爪 2025-01-02 02:47:42

我在 Vaadin 7.4.8 中仍然遇到类似的问题,并且能够使其工作。

1 - 我确定的第一件事是父组件(在我的例子中,我有两个 VerticalLayout 被添加到另一个组件中)具有 setSizeFull()。它们被添加到视图中。就我而言,我忘记将其设置在扩展 VerticalLayout 和 Implements View 的类上,由导航器调用。

2 - 另一个重要的细节是 tabSheet - 使用 addTab(component) 添加的选项卡还必须设置 setSizeFull() ,以便选项卡占用所有未使用的空间,特别是在底部。

2.1 - 添加了 setExpandRatio(tabSheet, 1) 以便它向顶部移动。

3 - 现在,对于使用 addTab(component) 添加到 tabSheet 的组件(VerticalLayout),我添加了两个组件,一个是 Horizo​​ntalLayout,第二个是 VerticalLayout。

所以我确保:

  • 它有 setSizeFull
  • setExpandRatio(Horizo​​ntalLayout, .5f);
  • setExpandRatio(VerticalLayout, .5f);

I was still experiencing similar issues in Vaadin 7.4.8 and was able to make it work.

1 - The first thing I made sure was that parent components(in my case I had two VerticalLayout's being added one into another) had setSizeFull(). They are being added to a View. In my case, I forgot to set it on a Class that extends VerticalLayout and Implements View, called by navigator.

2 - The other important detail is that the tabSheet - on which tabs were added with addTab(component) must also have a setSizeFull() being set, so that the tab takes all unused space, especially on towards the bottom.

2.1 - Added a setExpandRatio(tabSheet, 1) so that it is being shifted towards the top.

3 - Now, for a component(VerticalLayout) that is being added to a tabSheet using addTab(component), I had two components added to it, one is a HorizontalLayout and the second one is a VerticalLayout.

So I made sure that :

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