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

XP L&F: REGRESSION: setBackground on JButton sets border color in Windows XP

    XMLWordPrintable

Details

    Description



      Name: rmT116609 Date: 06/18/2003


      FULL PRODUCT VERSION :
      [c:\java\work]java -version
      java version "1.4.2-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19)
      Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode)

      FULL OS VERSION :
      4NT 4.01A Windows XP 5.1

      A DESCRIPTION OF THE PROBLEM :
      When using the XP Look-and-Feel in Java 1.4.2, setBackground() no longer sets the background color of the button. Instead, it sets an edge color. This only happens when using the XP Look-and-Feel; setBackground() works correctly when the -Dswing.noxp flag is used.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the program shown below. For example:

      \j2sdk1.4.1_02\bin\java ButtonTest
      \j2sdk1.4.2\bin\java ButtonTest
      \j2sdk1.4.2\bin\java -Dswing.noxp ButtonTest


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      This program should show the buttons as fully red, yellow and green. This works correctly in 1.4.1_02 and in 1.4.2 when using -Dswing.noxp.
      ACTUAL -
      In 1.4.2 using the XP Look-and-Feel, the buttons only show a band of color around the edges.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      import java.awt.*;

      public class ButtonTest extends JFrame
      {
        public ButtonTest()
        {
          super("ButtonTest");

      try { javax.swing.UIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel()); }
      catch(Exception e){e.printStackTrace();}

          Container pane = getContentPane();
          pane.setLayout(new GridLayout(0,1,10,10));

          JButton red = new JButton("Red");
          red.setBackground(Color.RED);
          pane.add(red);

          JButton yellow = new JButton("Yellow");
          yellow.setBackground(Color.YELLOW);
          pane.add(yellow);

          JButton green = new JButton("Green");
          green.setBackground(Color.GREEN);
          pane.add(green);
        }

        public static void main(String args[])
        {
          JFrame frame = new ButtonTest();
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setSize(120, 180);
          frame.setVisible(true);
        }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None. The -Dswing.noxp flag isn't an option because we generally want the XP Look-and-Feel.

      Release Regression From : 1.4.1_03
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Review ID: 188492)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              leifs Leif Samuelsson (Inactive)
              rmandalasunw Ranjith Mandala (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: