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

REGRESSION:JApplets, JDialogs and JFrame are empty

XMLWordPrintable

    • x86
    • windows_xp

      With Java 7 we have the problem that many JApplets , JDialogs and JFrams are empty.
      There is only a gray surface. After debugging and find the cause of the problem.
      Adding a component to the content pane does not invalidate the JApplet, JDialog or JFrame.

      In Java 6 and before the parent object was invalidate in this case.

       

      Workaround:

      Calling manual invalidate() after any change on the root objects.


      Sample Code:

      import java.awt.BorderLayout;
      import java.awt.Container;
      import javax.swing.*;

      public class TestApplet extends JApplet {
          @Override
          public void init() {
              validate();

              JSplitPane split = new JSplitPane();
              split.setLeftComponent( new JLabel( "left" ) );
              split.setRightComponent( new JLabel( "Right" ) );
              getContentPane().add( split, BorderLayout.CENTER );

              Container container = split;
              while( container != null ) {
                  System.err.println( container.getClass().getName() + " " + (container.isValid() ? "" : "invalid") );
                  container = container.getParent();
              }

              //workaround: call manual invalidate()
              //invalidate();
          }
      }
       

      Output from Java 6:
      ===============
      javax.swing.JSplitPane invalid
      javax.swing.JPanel invalid
      javax.swing.JLayeredPane invalid
      javax.swing.JRootPane invalid
      TestApplet invalid
      sun.applet.AppletViewerPanel invalid
      sun.applet.AppletViewer invalid


      Output from Java 7:
      ===================
      javax.swing.JSplitPane invalid
      javax.swing.JPanel invalid
      javax.swing.JLayeredPane invalid
      javax.swing.JRootPane invalid
      TestApplet
      sun.applet.AppletViewerPanel
      sun.applet.AppletViewer

            ngthomas Thomas Ng (Inactive)
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: