Good news... repaint() is asynchronous and thus can be called from any thread.
Having said that, it is possible to back yourself into a difficult corner when using multithreaded apps with synchronization. Most notably, deadlock can occur if your paint() requires synchronized objects/locks. Of course you should avoid this whenever possible since it imposes a lock overhead in your paint thread and you would like to avoid this, but it isn't always possible. If your application hangs, then you may need to be careful about how you call repaint() (or SwingUtilities.invokeLater(), or SwingUtilities.invokeAndWait() for that matter). I have been writing Swing apps the same way as you since the beginning and though I've seen the info about using SwingUtilities.invokeLater() I never switched my apps and I haven't had any real problems. Just my 2 cents there. This is not at all on the topic of Java2D, but I figure help is help. Mike > -----Original Message----- > From: Discussion list for Java 2D API > [mailto:[EMAIL PROTECTED] Behalf Of Rob Ross > Sent: Tuesday, July 13, 2004 2:45 PM > To: [EMAIL PROTECTED] > Subject: [JAVA2D] calling repaint() > > > This is semi-swing related, but since there's not a > swing-interest list and since it's also semi 2D related, I > thought I'd try here. > > I learned this past JavaOne that every swing app I have ever > written has been broken, as I often do > > public static void main(String[] args) > { > JFrame f = new JFrame(); > f.setVisible(true); > } > > when in fact I should be calling this from the event handling > thread via a SwingUtilities.invokeLater() call. > > My question is, can I call repaint() on a component from > another thread, or does that also have to be called from > within the event thread? Doesn't repaint just queue a request > for later processing anyway? If so, why would I need to spawn > a separate thread just to call the repaint? > > Rob > > ============================================================== > ============= > To unsubscribe, send email to [EMAIL PROTECTED] and > include in the body > of the message "signoff JAVA2D-INTEREST". For general help, > send email to > [EMAIL PROTECTED] and include in the body of the message "help". > =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".