Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2004

Tip: Looking for answers? Try searching our database.

How to decide paint completed?

Thread view: 
hiwa - 19 Dec 2004 06:44 GMT
My application class constructor instantiates a JPanel extended class
which does a complex drawing at the initial showing. In the last part
of the same constructor I call a screen capture method that uses java.awt
Robot and javax.imageio to get a JPEG file of the drawing panel. The
problem is that unless I put a Thread.sleep() for two or three second
delay before the capture call, captured JPEG is sheer blank. If I could
use a while loop for waiting the completion of the drawing and the
layout in the container, what could be the conditional expression to
be written in the while clause?

Thanks in advance for all the Java GUI gurus.
Michael Rauscher - 19 Dec 2004 08:29 GMT
> My application class constructor instantiates a JPanel extended class
> which does a complex drawing at the initial showing. In the last part
[quoted text clipped - 5 lines]
> layout in the container, what could be the conditional expression to
> be written in the while clause?

The problem seems to be, that you're accessing awt/Swing methods from
outside the event dispatch thread.

Therefore it might be that not all pending events has been processed
before you capture the screen. Try to use invokeLater
(SwingUtilities/EventQueue) to call your capture method.

Bye
Michael


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.