JavaFX Tab fit full size of header

后端 未结 3 1945
梦如初夏
梦如初夏 2021-01-15 16:21

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

3条回答
  •  北荒
    北荒 (楼主)
    2021-01-15 16:40

    It's true, the property objects of tabs are READ-Only. This means that you cannot manually set the properties. However, the values of the read-only properties can be bound to other properties, also the properties have some manipulation methods e.g. divide, subtract, please check the documentation for extended information.

    You can call the .tabminWidthProperty() on the tabpane and bind it to the width-property value of the parent of the layout.

    Here's the code to size all available tabs equally filling the whole screen:

    tabpane.tabMinWidthProperty().bind(root.widthProperty().divide(tabpane.getTabs().size()).subtract(20));
    

    I subtracted 20 to avoid the horizontal/vertical scrollbar. Surely there is also a way to disable them to pop up at all, but I'm an Android Dev and a greenhorn in JavaFx.

提交回复
热议问题