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

NullPointerException in swing.plaf.synth.SynthLookAndFeel$Handler

    Details

      Description

      FULL PRODUCT VERSION :
      javac 1.6.0
      java version 1.6.0

      ADDITIONAL OS VERSION INFORMATION :
      Red Hat Enterprise Linux 3 (2.4.21-37.EL)

      A DESCRIPTION OF THE PROBLEM :

      After uninstalling the UI on closed/disposed JDialogs, Linux clients will see the exception below. This makes the application appear broken and will generate support calls from our customers.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :

      1. Compile and Run sample program on linux using JDK/JRE 1.6
      2. In the sample program click button to launch a dialog (dialog A)
      3. Once open, close dialog A with the uper right corner X.
      4. Notice the NullPointerException (NPE) in the console console

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -

      No exception should be noted.
      ACTUAL -

      Exception noted (see Error Messages)



      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
      at javax.swing.plaf.synth.SynthLookAndFeel$Handler.repaintIfBackgrounds
      Differ(SynthLookAndFeel.java:917)
      at javax.swing.plaf.synth.SynthLookAndFeel$Handler.propertyChange(SynthLookAndFeel.java:878)
      at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339)
      at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276)
      at java.awt.KeyboardFocusManager.firePropertyChange(KeyboardFocusManager.java:1387)
      at java.awt.KeyboardFocusManager.setGlobalFocusOwner(KeyboardFocusManager.java:525)
      at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:521)
              at java.awt.Component.dispatchEventImpl(Component.java:4282)
              at java.awt.Container.dispatchEventImpl(Container.java:2116)
              at java.awt.Component.dispatchEvent(Component.java:4240)
              at sun.awt.X11.XWindow$1.run(XWindow.java:352)
              at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
              at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
              at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.lang.reflect.*;

      import java.awt.*;
      import java.awt.event.*;

      import javax.swing.*;
      import javax.swing.plaf.*;


      public class RepaintNPE extends JFrame
                              implements ActionListener
      {
          private static class DumbDialog extends JDialog
          {
              public DumbDialog ( JFrame parent )
              {
                  super ( parent, "DumbDialog", true );

                  setDefaultCloseOperation ( DISPOSE_ON_CLOSE );

                  JEditorPane editorPane = new JEditorPane();
                  editorPane.setContentType ( "text/html" );
                  editorPane.setEditable ( false );

                  JScrollPane scrollPane = new JScrollPane ( editorPane );

                  add( scrollPane );

                  setSize( 400, 400 );

                  setVisible( true );
              }

              public void dispose()
              {
                  super.dispose();

                  myDispose( this );
              }

              private void myDispose( Container container )
              {
                  Component[] components = container.getComponents ();

                  for ( Component comp : components )
                  {
                      // Special dispose for JComponent's remove UI
                      if ( comp instanceof JComponent )
                      {
                          JComponent jComp = (JComponent)comp;

                          try
                          {
                              Method method = jComp.getClass().getMethod ( "getUI" );

                              ComponentUI compUI =
                                       (ComponentUI)method.invoke ( jComp );
                              compUI.uninstallUI ( jComp );
                          }
                          catch ( Throwable t )
                          {
                              //t.printStackTrace();
                          }

                          // Recurse children
                          myDispose( jComp );
                      }
                  }
              }

          }

          private JButton showDialogButton = null;

          public RepaintNPE ()
          {
              setDefaultCloseOperation( EXIT_ON_CLOSE );

              showDialogButton = new JButton( "Show Dialog" );
              showDialogButton.addActionListener( this );

              add ( showDialogButton );

              setSize( 100, 100 );

              setVisible( true );

          }

          public void actionPerformed ( ActionEvent e )
          {
              if ( e.getSource() == showDialogButton )
              {
                  new DumbDialog ( this );
              }
          }

          public static void main ( String args [] )
          {
              SwingUtilities.invokeLater ( new Runnable()
              {
                  public void run()
                  {
                      try
                      {
                          UIManager.setLookAndFeel(
                                        UIManager.getSystemLookAndFeelClassName() );
                      }
                      catch ( Throwable t )
                      {
                          t.printStackTrace();
                      }

                      new RepaintNPE ();
                  }
              } );

          }
      }


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

      CUSTOMER SUBMITTED WORKAROUND :

      None as of yet.

        Attachments

          Activity

            People

            • Assignee:
              serb Sergey Bylokhov
              Reporter:
              ryeung Roger Yeung (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: