JavaFX Tab fit full size of header

后端 未结 3 1985
梦如初夏
梦如初夏 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:26

    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;
    

    Divide the width by number of tabs:

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

提交回复
热议问题