Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8166025

TableColumnHeader: loses custom style classes


    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u102, 9
    • Fix Version/s: 9
    • Component/s: javafx


      This happens when the styleclass of its tableColumn is changed. An example of a "custom" style is "nested-column-header" (but note: it's really only an example, happens to all custom styles in all custom header!)

      Below is an example that demonstrates the effect: it has a custom style rule for a nested column under a nested column (white background and padding to see). Run and

      - see the custom style in the second column
      - click on the button to add a style to the tableColumn
      - expected: custom style unchanged
      - actual: custom style vanished

      Reason: TableColumnHeader has a listener to the column's styleClass which overwrites any custom settings.

      import java.net.URL;

      //import de.swingempire.fx.utils.FXUtils;
      import javafx.application.Application;
      import javafx.scene.Parent;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.TableColumn;
      import javafx.scene.control.TableView;
      import javafx.scene.layout.BorderPane;
      import javafx.stage.Stage;

       * TableColumnHeader: Custom styles are lost. Here the "custom" is
      * nested-column-header.
       * @author Jeanette Winzenburg, Berlin
      @SuppressWarnings({ "rawtypes", "unchecked" })
      public class BugColumnHeaderStyle extends Application {

          private Parent getContent() {
              TableView table = new TableView();
              TableColumn single = new TableColumn("Single");
              TableColumn nested = new TableColumn("Nested");
              TableColumn childOne = new TableColumn("Child One");
              TableColumn childTwo = new TableColumn("Child Two");
              nested.getColumns().addAll(childOne, childTwo);
              table.getColumns().addAll(single, nested);
              Button addStyle = new Button("add style to TableColumn");
              addStyle.setOnAction(e -> nested.getStyleClass().add("dummy"));
              BorderPane pane = new BorderPane(table);
              return pane;

          public void start(Stage primaryStage) throws Exception {
              primaryStage.setScene(new Scene(getContent(), 600, 400));
              URL uri = getClass().getResource("headers.css");
      // primaryStage.setTitle(FXUtils.version());

          public static void main(String[] args) {

      Content of headers.css:
       * Just want to see an effect, doesn't matter what
      .nested-column-header > .nested-column-header {
      -fx-padding: 10;
      -fx-background-color: white;


          Issue Links



              • Assignee:
                jgiles Jonathan Giles
                fastegal Jeanette Winzenburg
              • Votes:
                0 Vote for this issue
                4 Start watching this issue


                • Created: