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

NullPointerException using WindowsProgressBarUI with unknown XPStyle pro

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:

      Description

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

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP Home SP2

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Our customer uses some (unknown to me) Windows XP-Style/Theme!

      A DESCRIPTION OF THE PROBLEM :
      Within our application (running on our customers machines) we get the following exception:

      java.lang.NullPointerException
      at java.awt.Dimension.<init>(Dimension.java:91)
      at javax.swing.plaf.basic.BasicProgressBarUI.getPreferredSize(BasicProgressBarUI.java:757)
      at javax.swing.JComponent.getPreferredSize(JComponent.java:1582)
      at java.awt.GridBagLayout.GetLayoutInfo(GridBagLayout.java:911)
      at java.awt.GridBagLayout.getLayoutInfo(GridBagLayout.java:816)
      at java.awt.GridBagLayout.ArrangeGrid(GridBagLayout.java:1412)
      at java.awt.GridBagLayout.arrangeGrid(GridBagLayout.java:1372)
      at java.awt.GridBagLayout.layoutContainer(GridBagLayout.java:712)
      at java.awt.Container.layout(Container.java:1401)
      at java.awt.Container.doLayout(Container.java:1390)
      at java.awt.Container.validateTree(Container.java:1473)
      at java.awt.Container.validateTree(Container.java:1480)
      at java.awt.Container.validateTree(Container.java:1480)
      at java.awt.Container.validateTree(Container.java:1480)
      at java.awt.Container.validateTree(Container.java:1480)
      at java.awt.Container.validate(Container.java:1448)
      at java.awt.Window.show(Window.java:507)
      at java.awt.Component.show(Component.java:1300)
      at java.awt.Component.setVisible(Component.java:1253)


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Since the problem only arises on our customers side where we do only have a very limited access, I think the cause of the problem is as follows.
      - Windows Look&Feel (com.sun.java.swing.plaf.windows.WindowsLookAndFeel)

      - XPStyle returns ´null´:
         /** Get a named <code>Dimension</code> value from the current style
           *
           * @param key a <code>String</code>
           * @return a <code>Dimension</code> or null if key is not found
           * in the current style
           */
          synchronized Dimension getDimension(String key) {
      Dimension d = (Dimension)map.get("Dimension "+key);
      // assume d==null
      if (d == null) {
      String str = getString(key);
      // assume str==null, skip if
      if (str != null) {
      StringTokenizer tok = new StringTokenizer(str, " \t,");
      d = new Dimension(parseInt(tok.nextToken(), 0),
      parseInt(tok.nextToken(), 0));
      map.put("Dimension "+key, d);
      }
      }
      // return null
      return d;
          }


      - then WindowsProgressBarUI returns ´null´
          protected Dimension getPreferredInnerHorizontal() {
      XPStyle xp = XPStyle.getXP();
      if (xp != null) {
      // return null
      return xp.getDimension("progress.bar.normalsize");
      } else {
      return super.getPreferredInnerHorizontal();
      }
          }

      - then BasicProgressBarUI feeds a null Dimension
          public Dimension getPreferredSize(JComponent c) {
      Dimension size;
      Insets border = progressBar.getInsets();
      FontMetrics fontSizer = progressBar.getFontMetrics(
                progressBar.getFont());

      if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
      // new Dimension( null ) !!
      size = new Dimension(getPreferredInnerHorizontal());
      ...
      into the new Dimension(..) which actually fails.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Use some default values, or have any fallback strategy, however no NPE

      ERROR MESSAGES/STACK TRACES THAT OCCUR :

      java.lang.NullPointerException
      at java.awt.Dimension.<init>(Dimension.java:91)
      at javax.swing.plaf.basic.BasicProgressBarUI.getPreferredSize(BasicProgressBarUI.java:757)
      at javax.swing.JComponent.getPreferredSize(JComponent.java:1582)
      at java.awt.GridBagLayout.GetLayoutInfo(GridBagLayout.java:911)
      at java.awt.GridBagLayout.getLayoutInfo(GridBagLayout.java:816)
      at java.awt.GridBagLayout.ArrangeGrid(GridBagLayout.java:1412)
      at java.awt.GridBagLayout.arrangeGrid(GridBagLayout.java:1372)
      at java.awt.GridBagLayout.layoutContainer(GridBagLayout.java:712)
      at java.awt.Container.layout(Container.java:1401)
      at java.awt.Container.doLayout(Container.java:1390)
      at java.awt.Container.validateTree(Container.java:1473)
      at java.awt.Container.validateTree(Container.java:1480)
      at java.awt.Container.validateTree(Container.java:1480)
      at java.awt.Container.validateTree(Container.java:1480)
      at java.awt.Container.validateTree(Container.java:1480)
      at java.awt.Container.validate(Container.java:1448)
      at java.awt.Window.show(Window.java:507)
      at java.awt.Component.show(Component.java:1300)
      at java.awt.Component.setVisible(Component.java:1253)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      switch XP Style back to default

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                shickeysunw Shannon Hickey (Inactive)
                Reporter:
                gmanwanisunw Girish Manwani (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: