Swing - Jframe repaint problem

Hi Guys,

I have a JFrame with many components added to it.say, JDesktopPane and I have added some 20 JTables inside a JScrollPane along with some JinternalFrames....

I am showing JDialog while clicking some button from JFrame.If I move the JDialog around the JFrame ...The JFrame creating some blank patches and after few seconds it comes back to its original look and feel..it seems some repaint problem in the JFrame....can anyone help me out in this....

Thanks,

Suresh

[502 byte] By [suresh@eproa] at [2007-11-26 23:18:52]
# 1

Hi Suresh;

Swing components must be executed in event dispatch thread only.

If your using ordinary thread then problem will be occurred as you said.

You must use SwingUtilities class to run swing components in event dispatch thread rather then using same thread.

Use SwingUtilities.invokeLater() static method to display your dialog box.

Ex:

Runnable runRemoveChild = new Runnable() {

public void run() { removeChild(child); //Call your Dialog Display Method Here

}

};

SwingUtilities.invokeLater( runRemoveChild );

Message was edited by:

Chowdary

Chowdarya at 2007-7-10 14:21:11 > top of Java-index,Desktop,Core GUI APIs...
# 2

This blog discusses some ways to determine if your code is violating the EDT rule:

http://weblogs.java.net/blog/alexfromsun/archive/2006/02/debugging_swing.html

However, the issue you describe sounds like the old gray rect problem:

http://weblogs.java.net/blog/zixle/archive/2005/04/no_more_gray_re_1.html

What version of Java are you using?

pthorsona at 2007-7-10 14:21:11 > top of Java-index,Desktop,Core GUI APIs...