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

Exception Painting ToolBarBorder after switch from XP Style to Classic

    XMLWordPrintable

Details

    • b16
    • x86
    • windows_xp

    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)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      If a floatable JToolBar is created while the XP Style prevails but not shown until after switching to the Classic style an exception occurs.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run supplied code (XPStyleProblem) and follow the instructions it presents.


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
              at com.sun.java.swing.plaf.windows.XPStyle$Skin.<init>(XPStyle.java:491)
              at com.sun.java.swing.plaf.windows.XPStyle$Skin.<init>(XPStyle.java:434)
              at com.sun.java.swing.plaf.windows.XPStyle.getSkin(XPStyle.java:424)
              at com.sun.java.swing.plaf.windows.WindowsBorders$ToolBarBorder.paintBorder(WindowsBorders.java:161)
              at javax.swing.JComponent.paintBorder(JComponent.java:901)
              at javax.swing.JToolBar.paintBorder(JToolBar.java:324)
              at javax.swing.JComponent.paint(JComponent.java:1004)
              at javax.swing.JComponent.paintChildren(JComponent.java:840)
              at javax.swing.JComponent.paint(JComponent.java:1012)
              at javax.swing.JComponent.paintChildren(JComponent.java:840)
              at javax.swing.JComponent.paint(JComponent.java:1012)
              at javax.swing.JLayeredPane.paint(JLayeredPane.java:559)
              at javax.swing.JComponent.paintChildren(JComponent.java:840)
              at javax.swing.JComponent.paint(JComponent.java:1012)
              at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4930)
              at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4883)
              at javax.swing.JComponent._paintImmediately(JComponent.java:4826)
              at javax.swing.JComponent.paintImmediately(JComponent.java:4633)
              at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
              at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.
      java:114)
              at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
              at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class XPStyleProblem {

          private static String instructions = "<HTML><BODY><OL>"
                                             + "<LI>Start with OS set to XP style</LI>"
                                             + "<LI>Switch OS to Classic style</LI>"
                                             + "<LI>Press the Show Toolbar button.</LI>"
                                             + "<LI>Observe exception.</LI>"
                                             + "</OL></BODY></HTML>";

          public static void main(String[] args) {

              try {UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}
              catch (Exception e) {}

              final JFrame frame = new JFrame("Style Change Problem");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

              final JToolBar toolBar = new JToolBar();
              toolBar.setVisible(false);
              JButton button = new JButton("1");
              toolBar.add(button);
              button = new JButton("2");
              toolBar.add(button);
              frame.getContentPane().add(toolBar, BorderLayout.NORTH);

              JLabel label = new JLabel(instructions);
              label.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
              frame.getContentPane().add(label, BorderLayout.CENTER);

              button = new JButton("Show Toolbar");
              button.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                      toolBar.setVisible(true);
                      frame.pack();
              }});
              Box box = Box.createHorizontalBox();
              box.add(Box.createHorizontalGlue());
              box.add(button);
              box.add(Box.createHorizontalGlue());
              frame.getContentPane().add(box, BorderLayout.SOUTH);

              frame.pack();
              frame.setVisible(true);
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Calling JToolBar.setFloatable(false) prevents the problem. If this isn't acceptable, other workarounds are probably possible.
      ###@###.### 2004-11-11 23:08:59 GMT

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: