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

Binding BooleanProperty objects with negation is akward

    XMLWordPrintable

Details

    Description

      Several times while working with the FX 2.0 pre-releases I have found myself in a situation where I want to bind two boolean properties with a negation. For instance, I want to bind a node's visibleProperty to the negation of a boolean property in one of my models. I haven't found a way to achieve this binding without doing something like the following:

      private static final BooleanProperty TRUE = new BooleanProperty(true);
      private static final BooleanProperty FALSE = new BooleanProperty(false);

      node.visibleProperty.bind(myModel.notVisibleProperty().isNotEqualTo(TRUE);

      The "notVisibleProperty" is a silly example but there are certainly cases where it makes sense to do this. It seems like aa not() method on BooleanProperty (BooleanExpression?) or perhaps bindNot(ObservableBooleanValue arg0) would be appropriate (the general not() method being more flexible). Or perhaps just define TRUE and FALSE as constants in the proper API class?. It seems strange that I have to define them myself in order to do this, but maybe I'm missing something in the APIs.

      Thanks!
      Kyle

      Attachments

        Activity

          People

            mheinrichs Michael Heinrichs (Inactive)
            kmcintyrejfx Kyle McIntyre (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: