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

Bugs in DefaultTreeCellRenderer.updateUI()

    Details

    • Subcomponent:
    • Resolved In Build:
      b08
    • OS:
      windows

      Description

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      I've found a couple of errors in the method: javax.swing.tree.DefaultTreeCellRenderer.updateUI().

      (1) There is a typo on one of the properties:

          if (!inited || (getOpenIcon() instanceof UIManager)) {

      That should be:

          if (!inited || (getOpenIcon() instanceof UIResource)) {

      (2) This part of the method causes incompatibilities between themes, because the border is not removed if the margins are null:

          Insets margins = DefaultLookup.getInsets(this, ui, "Tree.rendererMargins");
          if (margins != null) {
              setBorder(new EmptyBorder(margins.top, margins.left,
                      margins.bottom, margins.right));
          }

      E.g., the Nimbus L&F has the "Tree.rendererMargins" property, which sets the border. After switching to the Windows L&F, which does not have the property, the Nimbus border persists, upsetting the appearance of the tree. This code also doesn't honor any user-set border. Suggested fix (not tested):

          if (!inited || (getBorder() instanceof UIResource)) {
              Insets margins = DefaultLookup.getInsets(this, ui, "Tree.rendererMargins");
              if (margins != null) {
                  setBorder(new javax.swing.plaf.BorderUIResource.EmptyBorderUIResource(margins));
              } else {
                  setBorder(new javax.swing.plaf.BorderUIResource.EmptyBorderUIResource(0, 0, 0, 0));
              }
          }



      REPRODUCIBILITY :
      This bug can be reproduced always.

        Attachments

          Activity

            People

            • Assignee:
              trebari Tejpal Rebari
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: