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

JProgressBar resize exception, if setStringPainted in Windows LAF

    XMLWordPrintable

Details

    • b27
    • x86
    • windows_7

    Description

      FULL PRODUCT VERSION :
      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 [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      JProgressBar components throw an exception if resized to zero height, but only if setStringPainted(true) is set, and only if the look and feel is set to the default look and feel on Windows, or "com.sun.java.swing.plaf.windows.WindowsLookAndFeel".

      The bug is present in the most recent JDK 1.7 as well as 1.6.0_25-b06.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile the included source and the application. Resize the window, decreasing the height, until the progress bar is forced out of view.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No exception should be thrown
      ACTUAL -
      An IllegalArgumentException is thrown.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: negative width
              at java.awt.BasicStroke.<init>(BasicStroke.java:192)
              at java.awt.BasicStroke.<init>(BasicStroke.java:265)
              at com.sun.java.swing.plaf.windows.WindowsProgressBarUI.paintDeterminate(WindowsProgressBarUI.java:141)
              at javax.swing.plaf.basic.BasicProgressBarUI.paint(BasicProgressBarUI.java:412)
              at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
              at javax.swing.JComponent.paintComponent(JComponent.java:778)
              at javax.swing.JComponent.paint(JComponent.java:1054)
              at javax.swing.JComponent.paintChildren(JComponent.java:887)
              at javax.swing.JComponent.paint(JComponent.java:1063)
              at javax.swing.JComponent.paintChildren(JComponent.java:887)
              at javax.swing.JComponent.paint(JComponent.java:1063)
              at javax.swing.JLayeredPane.paint(JLayeredPane.java:585)
              at javax.swing.JComponent.paintChildren(JComponent.java:887)
              at javax.swing.JComponent.paintToOffscreen(JComponent.java:5228)
              at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1482)
              at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1413)
              at javax.swing.RepaintManager.paint(RepaintManager.java:1206)
              at javax.swing.JComponent.paint(JComponent.java:1040)
              at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:39)
              at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:78)
              at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:115)
              at java.awt.Container.paint(Container.java:1967)
              at java.awt.Window.paint(Window.java:3867)
             ...


      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class JProgressBarTest extends JFrame {
        public JProgressBarTest() {
          add(new JLabel("Above"), "North");
          JProgressBar bar = new JProgressBar();
          add(bar, "Center");
          add(new JLabel("Below"), "South");

          bar.setStringPainted(true);

          setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
          pack();
          setVisible(true);
        }

        public static void main(String[] args) throws Exception {
          // if running on windows
          // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
          
          // to force the LAF, assuming the class is available
          UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

          new JProgressBarTest();
        }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use a look-and-feel other than Windows.

      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: