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

Metal L&F hardcodes PropertyPrefix for gradients

    XMLWordPrintable

    Details

      Description

      FULL PRODUCT VERSION :
      java version "1.5.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
      Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Linux computer 2.6.5 #1 Mon May 24 13:55:25 MDT 2004 i686 Pentium III (Coppermine) GenuineIntel GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      Metal L&F classes hardcode the propertyPrefix when accessing gradients instead of using the getPropertyPrefix function making it more difficult to override the gradient colors when extending UI Classes.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Extend MetalButtonUI ( or any other UI that uses gradients) and override the getPropertyPrefix() function to return a new PropertyPrefix. Add new Gradient using UIManager.put(Object key, Object value).

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Assigning new UI should use the gradient for that begins with the new PropertyPrefix.
      ACTUAL -
      Component will still use the original gradient.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      import javax.swing.plaf.metal.*;
      import javax.swing.plaf.*;
      import javax.swing.*;
      import java.awt.event.*;
      import java.util.*;

      public class TestUI extends MetalButtonUI implements ActionListener
      {
              private final static TestUI testUI = new TestUI();

              public static ComponentUI createUI(JComponent c)
              {
                      return testUI;
              }

              public String getPropertyPrefix()
              {
                      return "TestUI.";
              }

              public void actionPerformed(ActionEvent e)
              {
                      System.exit(0);
              }

              public static void main(String args[])
              {
                      JFrame
                              frame = new JFrame("TestUI");

                      JButton
                              button = new JButton("Close");

                      ArrayList
                              list = new ArrayList();

                      list.add(new Double(1.0));
                      list.add(new Double(0.0));
                      list.add(new ColorUIResource(25, 35, 45));
                      list.add(new ColorUIResource(45, 45, 45));
                      list.add(new ColorUIResource(25, 35, 45));
                      UIManager.put("TestUI.gradient", list);

                      button.setUI((TestUI)TestUI.createUI(button));
                      button.addActionListener(testUI);
                      frame.getContentPane().add(button);
                      frame.pack();
                      frame.setVisible(true);
              }
      }

      ---------- END SOURCE ----------
      ###@###.### 2004-11-05 19:36:51 GMT

        Attachments

          Activity

            People

            Assignee:
            svioletsunw Scott Violet (Inactive)
            Reporter:
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: