gpt4 book ai didi

java - SWT 选项卡文件夹 : How do you automatically compress TabItems when there are too many

转载 作者:行者123 更新时间:2023-12-02 10:43:42 25 4
gpt4 key购买 nike

我有一个 TabFolder,可以在其中动态创建 TabItem。我期望选项卡会像在浏览器中那样压缩,当您的选项卡超出屏幕大小时,但除非我添加水平滚动条,否则它们只是不断向屏幕右侧扩展。有没有办法让它们像这样自动压缩?

TabFolder tabsComposite = new TabFolder(builder, SWT.NONE);
tabsComposite.setLayout(new GridLayout(1, false));
GridData tabsLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
tabsComposite.setLayoutData(tabsLayoutData);

这些是通过另一种方法中的按钮单击创建的,并且可以创建任意数量的

TabItem item = new TabItem(tabsComposite, SWT.NONE);
tableComposite = new Composite(parent, SWT.BORDER);
GridData tableLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
tableComposite.setLayoutData(tableLayoutData);
GridLayout tableLayout = new GridLayout(1, false);
tableComposite.setLayout(tableLayout);
item.setText(nameText.getText());

最佳答案

正如 @greg-449 提到的,您可以使用 CTabFolder 来完成此操作。默认情况下,CTabFolder 将显示不少于 20 characters压缩时,因此如果选项卡标题不够长,您可能不会注意到此默认行为。

您可以调用CTabFolder.setMinimumCharacters(int)如果你想改变这个值。

默认行为:

enter image description here

使用新的最低设置:

enter image description here

关于java - SWT 选项卡文件夹 : How do you automatically compress TabItems when there are too many,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52745982/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com