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

DefaultTreeCellRenderer doesn't honor 'Tree.rendererFillBackground' LAF property

    XMLWordPrintable

Details

    • b27
    • x86
    • windows_7

    Description

      FULL PRODUCT VERSION :
      java version "1.7.0_02"
      Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
      Java HotSpot(TM) Client VM (build 22.0-b10, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]
      Microsoft Windows [Version 6.1.7600]

      A DESCRIPTION OF THE PROBLEM :
      DefaultTreeCellRenderer always paint it's background, even if LAF property 'Tree.rendererFillBackground' has been set to false. This is especially the case with Nimbus LAF, which sets 'Tree.rendererFillBackground' to false by default.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Regarding the LAF property 'Tree.rendererFillBackground', the tree cells should be rendered
      - opaque, if the property has been set to true
      - non-opaque, if the property has been set to false

      ACTUAL -
      The tree cells are always rendered opaque.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public static void main(String...args)
      {
      try
      {
      UIManager.setLookAndFeel( "javax.swing.plaf.nimbus.NimbusLookAndFeel" );
      UIManager.put("Tree.rendererFillBackground",Boolean.FALSE);
      UIManager.put("Tree.textBackground", Color.RED);

      DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
      for (int i=0; i<3; i++)
      {
      DefaultMutableTreeNode node1 = new DefaultMutableTreeNode("Node " + i);
      root.add(node1);

      for (int j=0; j<3; j++)
      {
      node1.add(new DefaultMutableTreeNode("Node " + i + "." + j));
      }
      }

      JTree tree = new JTree(root);
      tree.setCellRenderer( new DefaultTreeCellRenderer() );

      JFrame frame = new JFrame("DefaultTreeCellRenderer Bug Demo");
      frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
      frame.getContentPane().setLayout( new BorderLayout() );
      frame.getContentPane().add( new JScrollPane(tree) );
      frame.setSize( 600, 400 );
      frame.setVisible( true );
      }
      catch (Exception e)
      {
      e.printStackTrace();
      System.exit(1);
      }
      }
      ---------- END SOURCE ----------

      Attachments

        Activity

          People

            rupashka Pavel Porvatov (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: