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

[Layout] Use of Region.USE_COMPUTED_SIZE and USE_PREF_SIZE is inconsistent

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 8u20
    • javafx
    • None

      Region.USE_COMPUTED_SIZE is supposed to cause the compute[Min|Pref|Max][Width|Height] to return the region's intrinsic size. Region.USE_PREF_SIZE is supposed to cause the compute[Min|Max][Width|Height] to return the value of computePref[Width|Height]. The compute methods do not follow this.

      Example: Region computeMinHeight

          @Override protected double computeMinHeight(double width) {
              return getInsets().getTop() + getInsets().getBottom();
          }

      This code should be

          @Override protected double computeMinHeight(double width) {
              if (getMinHeight() == USE_PREF_SIZE) {
                   return computePrefHeight(width);
              }
              else if (getMinHeight() == USE_COMPUTED_SIZE || getMinHeight() < 0) {
                  return getInsets().getTop() + getInsets().getBottom();
              }
              else {
                  return getMinHeight();
              }
          }

      This affects any code that overrides these compute methods.

            msladecek Martin Sládeček
            dgrieve David Grieve
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: