-
Bug
-
Resolution: Duplicate
-
P2
-
7
-
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
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
- duplicates
-
JDK-6986229 Issues with loading of Swing based applets with JDK7
- Closed
- relates to
-
JDK-6987444 The applet set1/javasuncom_Java2DDemo.html can't be loaded and there is no exception
- Closed
-
JDK-7026051 appletviewer cannot show swing components
- Closed
-
JDK-7002856 Provide an accessor for Container.validateUnconditionally()
- Closed
-
JDK-7021116 Swing applets do not display in appletviewer unless they are resized.
- Closed
-
JDK-6852592 invalidate() must be smarter
- Resolved
(1 relates to)