NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: getImage exception

Hi Paul,

I believe the problem you encountered is similar to mine,
i.e. you may not call getImage() displayImpl.java directly
via AWT-Event Queue.

You may overcome this problem using the InvokeLater() method
of Java's SwingUtilities.

I avoided the same problem via implementing a method in my display 
manager directly through a direct thread. Someting like this:


class DisplayManager {
   ....
   DisplayImpl display;
   BufferredImage bimg;
   ....
   ....
   public void invokeGetImage()
   {
      // ************************************
      // *  Make a thread to do the job     *
      // ************************************
      Runnable captureImage = new Runnable() {
          public void run() {bimg=display.getImage();}
      };
      Thread t=new Thread(captureImage);
      t.start();
      
      ... wait for a while for thread to finish!...
      if(bimg!=null) { // you have image

        .... // do whatever you want
      }
   }
   ....
}

I hope the above would help.

Cheers

Ng Say Teong.


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