JavaFX Tab 适合标题的全尺寸 [英] JavaFX Tab fit full size of header

查看:45
本文介绍了JavaFX Tab 适合标题的全尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的选项卡中的选项卡适合它们所在的选项卡的完整大小.所以基本上不会有可见的标题区域,所有内容都应该被选项卡覆盖.

I want the tabs in my tabpane to fit the complete size of the tabpane which they are in. So basically there shall be no header area visible, everything should be covered by the tabs.

我有两个问题:

  • 如何使标签动态适应标签窗格的宽度?
  • 如何将它们调整到正确的高度,并删除标签之间的小空间?我想这是通过 css 完成的,但我不太清楚如何.

问候

推荐答案

您可以简单地向 TabPane 添加一个侦听器,以检测任何更改并相应地调整选项卡的宽度和/或高度.

You can simply add a listener to the TabPane to detect any changes and adjust the width and/or height of the tabs accordingly.

@FXML
private JFXTabPane tabPane;

将宽度除以选项卡数:

tabPane.widthProperty().addListener((observable, oldValue, newValue) ->
    {
        tabPane.setTabMinWidth(tabPane.getWidth() / tabPane.getTabs().size());
        tabPane.setTabMaxWidth(tabPane.getWidth() / tabPane.getTabs().size());      
    });

这篇关于JavaFX Tab 适合标题的全尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆