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

Synth Tree Icons doesn't appear

    XMLWordPrintable

Details

    • x86
    • windows_vista

    Description

      FULL PRODUCT VERSION :
      java version "1.6.0_10-beta"
      Java(TM) SE Runtime Environment (build 1.6.0_10-beta-b14)
      Java HotSpot(TM) Client VM (build 11.0-b11, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows Vista, Windows XP

      A DESCRIPTION OF THE PROBLEM :
      Configured tree icons won't appear. The following keys are default properties and can be used to set default tree icons:
      "Tree.leafIcon"
      "Tree.openIcon"
      "Tree.closedIcon"

      When the keys are configured within a Synth XML file, the icons won't appear - see test case.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See test case. If you're using a different package don't forget to modify the synth configuration ( " <object id=\"treeIcon\" class=\"test.synth.SynthTreeIconTest$TreeIcon\"/>")

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The red rectangles should appear.
      ACTUAL -
      No red rectangles appear.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      package test.synth;

      import java.awt.Color;
      import java.awt.Component;
      import java.awt.Dimension;
      import java.awt.EventQueue;
      import java.awt.Graphics;
      import java.io.ByteArrayInputStream;
      import java.io.InputStream;

      import javax.swing.Icon;
      import javax.swing.JFrame;
      import javax.swing.JTree;
      import javax.swing.UIManager;
      import javax.swing.plaf.synth.SynthLookAndFeel;

      public class SynthTreeIconTest extends JFrame
      {
        private static String synthXml = "<synth>" +
        " <style id=\"all\">" +
        " <font name=\"Dialog\" size=\"12\"/>" +
        " </style>" +
        " <bind style=\"all\" type=\"REGION\" key=\".*\"/>" +
        " <style id=\"tree\">" +
        " <object id=\"treeIcon\" class=\"test.synth.SynthTreeIconTest$TreeIcon\"/>" +
        " <property key=\"Tree.leftChildIndent\" type=\"integer\" value=\"4\"/> " +
        " <property key=\"Tree.rightChildIndent\" type=\"integer\" value=\"12\"/> " +
        " <state>" +
        " <defaultsProperty key=\"Tree.leafIcon\" type=\"idref\" value=\"treeIcon\"/>" +
        " <defaultsProperty key=\"Tree.openIcon\" type=\"idref\" value=\"treeIcon\"/>" +
        " <defaultsProperty key=\"Tree.closedIcon\" type=\"idref\" value=\"treeIcon\"/>" +
        " </state>" +
        " </style>" +
        " <bind style=\"tree\" type=\"region\" key=\"Tree\"/>" +
        "</synth>";
        
        public static void main(String[] args)
        {
          EventQueue.invokeLater(new Runnable(){
            public void run()
            {
              try
              {
                new SynthTreeIconTest();
              }
              catch (Exception e)
              {
                e.printStackTrace();
              }
            }
          });
        }

        public SynthTreeIconTest() throws Exception
        {
          InputStream is = new ByteArrayInputStream(synthXml.getBytes("UTF8"));
          SynthLookAndFeel laf = new SynthLookAndFeel();
          laf.load(is, SynthTreeIconTest.class);
          UIManager.setLookAndFeel(laf);

          JTree tree = new JTree();
          add(tree);

          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setSize(new Dimension(400, 300));
          setLocationRelativeTo(null);
          setVisible(true);
        }
        
        public static class TreeIcon implements Icon
        {
          public void paintIcon(Component c, Graphics g, int x, int y)
          {
            g.setColor(Color.RED);
            g.drawRect(x, y, getIconWidth()-1, getIconHeight()-1);
          }

          public int getIconWidth()
          {
            return 12;
          }

          public int getIconHeight()
          {
            return 12;
          }
        }
        
      }

      Attachments

        Activity

          People

            peterz Peter Zhelezniakov
            igor Igor Nekrestyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: