Re: problems of Java 2D display put in an internal frame

  • To: m huang <qomo@xxxxxxxxx>
  • Subject: Re: problems of Java 2D display put in an internal frame
  • From: Bill Hibbard <billh@xxxxxxxxxxxxx>
  • Date: Tue, 25 Feb 2003 09:05:38 -0600 (CST)
Hi Maohai,

Thanks for finding this, and thanks for the test program.
The fix is in:

  ftp://ftp.ssec.wisc.edu/pub/visad-2.0/untested/VisADCanvasJ2D.java

Cheers,
Bill

On Tue, 25 Feb 2003, m huang wrote:

> hi,
>
> 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:
>
> java.lang.NullPointerException
>         at visad.MouseHelper.enableFunctions(MouseHelper.java:566)
>         at visad.MouseHelper.processEvent(MouseHelper.java:378)
>         at visad.MouseHelper.processEvent(MouseHelper.java:138)
>         at
> visad.java2d.VisADCanvasJ2D$2.mousePressed(VisADCanvasJ2D.java:204)
>         at java.awt.Component.processMouseEvent(Component.java:5090)
>         at java.awt.Component.processEvent(Component.java:4890)
>         at java.awt.Container.processEvent(Container.java:1566)
>         at java.awt.Component.dispatchEventImpl(Component.java:3598)
>         at java.awt.Container.dispatchEventImpl(Container.java:1623)
>         at java.awt.Component.dispatchEvent(Component.java:3439)
> ....
>
> 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
> show!
>
> 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);
>       f1.getContentPane().validate();
>       f1.pack();
>       f1.setLocation(80,80);
>       f1.setVisible(true);
>       desk.add (f1);
>       f1.moveToFront();
>     }
>
>     static void useFrames(String[] av) {
>
>       jf.setSize(400,400);
>       jf.setContentPane (desk);
>       jf.setVisible(true);
>
>       // a JPanel
>       JPanel jp = new JPanel();
>       jp.setPreferredSize(new Dimension(200,200));
>       add(jp);
>
>       // a label
>       JLabel jl=new JLabel("sssss");
>       add(jl);
>
>
>       //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) {
>       useFrames(av);
>     }
> }
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Tax Center - forms, calculators, tips, more
> http://taxes.yahoo.com/
>
>


  • 2003 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: