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

REGRESSION: XP L&F: Background color on JProgressBar does not work in WinXP

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.4.2
    • client-libs



      Name: rmT116609 Date: 05/13/2004


      FULL PRODUCT VERSION :
      java version "1.4.2"
      Java(TM) 2 Runtime Envrionment, Standard Edition (build 1.4.2-b28)
      Java HotSpot (TM) Clinet VM (build 1.4.2-b28, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP Version 2002 SP 1

      A DESCRIPTION OF THE PROBLEM :
      Setting the background color on JProgressBar does not work in XP L&F in JRE 1.4.2. This used to work in 1.4.1. Even in 1.4.2, with other L&F like metal L&F, it works properly and shows the background color set on the component. With XP L&F, it always shows white background.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the test case.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The progress bar should show with red color as background. When the task proceeds, the progress is indicated by the green foreground color.
      ACTUAL -
      The progress bar shows up with white background color, which is then filled with green foreground color.

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class ProgressBar extends JPanel {

          private JProgressBar progressBar;

          public ProgressBar() {
              super(new BorderLayout());


              progressBar = new JProgressBar(0, 20);
              progressBar.setValue(0);
              progressBar.setStringPainted(true);
              progressBar.setForeground(Color.green);
              progressBar.setBackground(Color.red);
              progressBar.setOpaque(true);


              JPanel panel = new JPanel();
              panel.add(progressBar);

              add(panel, BorderLayout.PAGE_START);
              setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));


          }

          /**
           * Create the GUI and show it. For thread safety,
           * this method should be invoked from the
           * event-dispatching thread.
           */
          private static void createAndShowGUI() {
              //Make sure we have nice window decorations.
              JFrame.setDefaultLookAndFeelDecorated(true);

              //Create and set up the window.
              JFrame frame = new JFrame("ProgressBarDemo");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

              //Create and set up the content pane.
              JComponent newContentPane = new ProgressBar();
              newContentPane.setOpaque(true); //content panes must be opaque
              frame.setContentPane(newContentPane);

              //Display the window.
              frame.pack();
              frame.setVisible(true);
          }

          public static void main(String[] args) {

            try
              {
       
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              }
              catch (Exception e)
              { }
             createAndShowGUI();
          }
      }
      ---------- END SOURCE ----------

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

      (Incident Review ID: 265350)
      ======================================================================

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: