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

Change BehaviorSkinBase registerChangeListener to use Callback functional interface rather than strings

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 8u20
    • javafx
    • None

      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

            Unassigned Unassigned
            dgrieve David Grieve
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: