I like the idea from Alexander Chingarev, but I think the code will leak a memory! Each time the width property changes, a new listener is registered, and older listeners never collect garbage! Thus, you can either save the link to the listener, but also remove it from the observed value (in this case, this is a reordering property) before adding a new listener or make sure that the listener is added only once to the reordering property.
I used the skin property, which changes only once (if I'm not mistaken) to add my listener:
tableView.skinProperty().addListener((obs, oldSkin, newSkin) -> { final TableHeaderRow header = (TableHeaderRow) lookup("TableHeaderRow"); header.reorderingProperty().addListener((o, oldVal, newVal) -> header.setReordering(false)); });
Jopolka
source share