1

I'm trying to set css for a TabPane in JavaFX. I have two TabPanes created but for one of the TabPanes I used CSS to hide the tabs (weird I know) while the other TabPane I intend on using the default css.

However when I go to apply the css, it is applying to both the nodes. How do I fix this issue so that only one of the TabPanes use the css?

Code:

    tabPane.getStyleClass().add("customTab");
    tabPane.getStylesheets().add("/resources/css/TabPane.css");

CSS

.customTab{
    -fx-tab-max-height: 0 ;
}

.customTab .tab-header-area {
    visibility: hidden ;
}

.customTab .tab-header-area .tab-header-background {
    -fx-background-color: #f4f4f4;
}

.customTab .tab {
    -fx-background-color: #f4f4f4;
}
.customTab .detailed .tab {
    -fx-background-color: #f4f4f4;
}

.customTab .detailed .tab-header-area .tab-header-background {
    -fx-background-color: #f4f4f4;
}

I have also tried following this post and using "setId()" but got the same results.

#customTab .tab-header-area {
    visibility: hidden ;
}

and

.customTab.tab-header-area {
    visibility: hidden ;
}

and

.customTab > .tab-header-area {
    visibility: hidden ;
}

Please inform me the correct way of doing this.

Thank you.

Kadana Kanz
  • 177
  • 2
  • 11
  • If you only call `tabPane.getStyleClass().add("customTab")` on one of the tab panes, it should work the way you want. Are you calling that on both tab panes, for some reason? – James_D Nov 26 '17 at 19:31
  • @James_D Nope, just double checked both the controller code for the class and the FXML... but I think I found out one of the reasons and might have to change the question a little bit. The second TabPane (the one with the TabHeaderArea visible) resides within a tab on the FIRST TabPane which has the header area hidden so I'm guessing it is inheriting it...? – Kadana Kanz Nov 26 '17 at 19:46
  • Yes, that would explain it. You probably need selectors like `.customTab > .tab-header-area` and `.customTab > .tab-header.area > .tab` throughout. – James_D Nov 26 '17 at 19:50

0 Answers0