Even though what to do with BehaviorSkinBase is up for debate, we can make it marginally better by replacing:
- protected final void registerChangeListener(ObservableValue<?> property, String reference) {
+ protected final void registerChangeListener(ObservableValue<?> property, Callback<ObservableValue<?>, Void> callback) {
This would do away with the monolithic handleControlPropertyChanged and allow for use of lambda's. Besides the novelty and fun of using lambda, this would make for cleaner skin code. For example, in LabeledSkinBase, instead of
registerChangeListener(labeled.fontProperty(), "FONT");
with the big if-then-else block that is handleControlPropertyChanged, we'd have
registerChangeListener(labeled.fontProperty(), (observable) -> {
textMetricsChanged();
invalidateWidths();
ellipsisWidth = Double.NEGATIVE_INFINITY;
}
Attached patch.patch which is a quick pass at the changes that would be made in BehaviorSkinBase and MultiplePropertyChangeListenerHandler
- protected final void registerChangeListener(ObservableValue<?> property, String reference) {
+ protected final void registerChangeListener(ObservableValue<?> property, Callback<ObservableValue<?>, Void> callback) {
This would do away with the monolithic handleControlPropertyChanged and allow for use of lambda's. Besides the novelty and fun of using lambda, this would make for cleaner skin code. For example, in LabeledSkinBase, instead of
registerChangeListener(labeled.fontProperty(), "FONT");
with the big if-then-else block that is handleControlPropertyChanged, we'd have
registerChangeListener(labeled.fontProperty(), (observable) -> {
textMetricsChanged();
invalidateWidths();
ellipsisWidth = Double.NEGATIVE_INFINITY;
}
Attached patch.patch which is a quick pass at the changes that would be made in BehaviorSkinBase and MultiplePropertyChangeListenerHandler
- relates to
-
JDK-8091189 Move BehaviorBase into public API
- Open