RE: display.getImage()

Hi Ibrahim,

The POLYGON_LINE mode probably affects this because it makes
rendering faster. That is, you have a race condition between
the disappearence of the JFileChooser and rendering your
image. So you might insert a simple delay in your Thread,
after you close the JFileChooser and before the call to
getImage(). You might also try getImage(true). This is the
kind of problem where you should experiment with various
approaches.

Good luck,
Bill

On Tue, 14 Jan 2003, Ibrahim Z Mohammad wrote:

> Thanks a lot for your help. I created my new Thread object and called
> display.getImage() from its run() method and it worked fine. However I
> have a curious problem when I try to save an image when the display is
> in POLYGON_LINE mode. My GUI creates a JFileChooser to save the image as
> a jpeg which covers the display temporarily while the user enters the
> file name etc. After the user clicks on 'Save', the JFileChooser
> disappears and the image gets saved as a jpeg of the given name in the
> given directory. This works fine if the display mode is 'POLYGON_FILL',
> but in the 'POLYGON_LINE' mode the disappearing JFileChooser leaves a
> grey area on the part of the display behind it in the saved jpeg. Is
> this behavior predictable? And how can I get around it?
>
> Thanks again,
>
> Ibrahim
>
>
>
> -----Original Message-----
> From: Luke Matthews [mailto:l.matthews@xxxxxxxxxx]
> Sent: Tuesday, January 14, 2003 12:22 AM
> To: Ibrahim Z Mohammad
> Subject: Re: display.getImage()
>
> Hi Ibrahim,
>
> Basically what the exception is telling you is that getImage() does not
> like being called from the event thread. What you need to do is execute
> the code (ie the call to display.getImage()) in another thread. Sun
> provides a handy little class to do this called SwingWorker. You can
> find it on their website. I am a bit short on time at the moment so I
> cannot explain fully how to use it. Just go to the website and hunt
> around the tutorial it is in their somewhere around threads.
>
> Hope this helps you out.
>
> Luke Matthews.
>
> On Sun, 2003-01-12 at 10:41, Ibrahim Z Mohammad wrote:
> > I'm sorry, I should have added this to the last email. I have a
> problem when I try to use display.getImage(), I get an exception that
> says
> >
> > Exception occurred during event dispatching:
> > visad.VisADError: cannot call getImage() from Thread: AWT-EventQueue-0
> >             at visad.DisplayImpl.getImage(DisplayImpl.java:2090)
> > I cannot understand what this means or why I'm getting this exception.
> Your help would be greatly appreciated.
> >
> > Thanks!
> > Ibrahim
> >
>
>
>
>
>