--- old/modules/javafx.controls/src/main/java/javafx/scene/control/skin/TableColumnHeader.java 2016-09-29 13:31:01.000000000 +1300 +++ new/modules/javafx.controls/src/main/java/javafx/scene/control/skin/TableColumnHeader.java 2016-09-29 13:31:01.000000000 +1300 @@ -86,6 +86,8 @@ * * **************************************************************************/ + static final String DEFAULT_STYLE_CLASS = "column-header"; + // Copied from TableColumn. The value here should always be in-sync with // the value in TableColumn static final double DEFAULT_COLUMN_WIDTH = 80.0F; @@ -147,6 +149,8 @@ * @param tc The table column to be visually represented by this instance. */ public TableColumnHeader(final TableViewSkinBase skin, final TableColumnBase tc) { + getStyleClass().setAll(DEFAULT_STYLE_CLASS); + this.skin = skin; setTableColumn(tc); this.columnReorderLine = skin.getColumnReorderLine(); @@ -188,11 +192,13 @@ changeListenerHandler.registerChangeListener(tc.textProperty(), e -> label.setText(tc.getText())); changeListenerHandler.registerChangeListener(tc.graphicProperty(), e -> label.setGraphic(tc.getGraphic())); + // add in all styleclasses from the table column into the header, and also set up a listener + // so that any subsequent changes to the table column are also applied to the header + getStyleClass().addAll(tc.getStyleClass()); tc.getStyleClass().addListener(weakStyleClassListener); setId(tc.getId()); setStyle(tc.getStyle()); - updateStyleClass(); /* Having TableColumn role parented by TableColumn causes VoiceOver to be unhappy */ setAccessibleRole(AccessibleRole.TABLE_COLUMN); } @@ -218,7 +224,14 @@ }; private ListChangeListener styleClassListener = c -> { - updateStyleClass(); + while (c.next()) { + if (c.wasRemoved()) { + getStyleClass().removeAll(c.getRemoved()); + } + if (c.wasAdded()) { + getStyleClass().addAll(c.getAddedSubList()); + } + } }; private WeakListChangeListener> weakSortOrderListener = @@ -471,13 +484,6 @@ } } - private void updateStyleClass() { - // For now we leave the 'column-header' style class intact so that the - // appropriate border styles are shown, etc. - getStyleClass().setAll("column-header"); - getStyleClass().addAll(getTableColumn().getStyleClass()); - } - private void updateScene() { // RT-17684: If the TableColumn widths are all currently the default, // we attempt to 'auto-size' based on the preferred width of the first