problems of Java 2D display put in an internal frame


I have an instance of  DisplayImplJ2D.
When I add the result of getComponent(), which is a
DisplayPanelJ2D, to an internal
frame I *sometimes* get a gray window without the plot.
If I get the gray window, I find 

1) the canvas field of
DisplayPanelJ2D actually does have the plot. This canvas
can be accessed by displayPanelJ2D.getComponents()[0]
It seems that the DisplayPanelJ2D isn't "activated".
I have looked at the source code of DisplayPanelJ2D and
couldn't find out why.

2) if click on it, i get these:

        at visad.MouseHelper.enableFunctions(
        at visad.MouseHelper.processEvent(
        at visad.MouseHelper.processEvent(
        at java.awt.Component.processMouseEvent(
        at java.awt.Component.processEvent(
        at java.awt.Container.processEvent(
        at java.awt.Component.dispatchEventImpl(
        at java.awt.Container.dispatchEventImpl(
        at java.awt.Component.dispatchEvent(

3) If I resize the internal frame the plot shows.

I have never had problems if I add the DisplayPanelJ2D to
a JFrame.

Similar problem has been reported in the list before but it
has never been reproduced and tracked down. I try to reproduce
the problem with something really simple but it sometimes
gives different result in different run. I put the code at the
end of the post. The last frame that shows, which is labeled
as "clas visad.java2d.DisplayPanelJ2D" is the interesting
window. the other windows have to be there or the problem doesn't

Since JInternalFrame is the only light weight conttainer
in in the Swing library. I wonder if the problem has something
to do with it.

btw I have read about the 3D display problem with JInternalFrames,
which is a separate problem.

any thoughts?

import java.awt.*;
import javax.swing.*;
import visad.java2d.*;

public class BadVis {
    // desk top
    static JFrame jf = new JFrame("foo");
    static JDesktopPane desk = new JDesktopPane();      

    public static void add(JComponent c) {
        JInternalFrame f1 = new JInternalFrame (c.getClass().toString(),
true, true, true, true);
        f1.getContentPane().add (c);
        desk.add (f1);

    static void useFrames(String[] av) {

        jf.setContentPane (desk);

        // a JPanel
        JPanel jp = new JPanel();
        jp.setPreferredSize(new Dimension(200,200));

        // a label
        JLabel jl=new JLabel("sssss");

        //VisAD plot
        DisplayImplJ2D d = null;
        try {
            d = new DisplayImplJ2D("dis");
        } catch (Exception e) {}
        Component c = d.getComponent();
        add ((JComponent) c);

    public static final void main(String[] av) {

Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more