Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Dialogs windows not displaying properly  RSS feed

 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a swing app which has a JFrame for a main container on this frame are several components (table, buttons etc). Several of the buttons cause dialog windows to open. One button opens another JFrame (was a separate app, but is now a pop up window in this app). The problem is after pushing the button for that opens this new window (and closing it) the other dialog windows won't paint correctly.

Originally the main window wouldn't repaint correctly but I fixed this by passing its frame to the other frame and calling its update method when the secondary/child frame closed.

I've looked through the archives here and must not have worded my search properly b/c I can't find much. Is there a tutorial online somewhere about the proper way to deal with multiple windows/frames and the repainting issues with them?

-Tad
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the event dispatch thread in one of the windows gets busy it may hold up system–triggered repaints of corrupted/uncovered guis. This test seems to work okay in j2se 1.5:
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hrm. It doesn't seem to just hold it up... but stop it. The window will repaint when you select/mouse over components (well each separate compontent will repaint). Only one window causes this problem (the frame/window that was originally written separately) all the other dialog/option windows don't cause this problem. I got the main window to refresh properly by passing it to the new frame(the one I wrote) and doing update(graphics) on close of the window. Everything looked kosher... then after opening the other dialogs they weren't repainting properly. Its frustrating, but maybe I can get it to fixed by having the second window (the one causisng the problems) to run its own thread (which it really should be doing anyway).

-Tad
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok this is really frustrating. I went ahead and used the swing worker class when invoking the 2nd frame object. But I stll end up with the weird behaviors on all the other windows. Strange thing it only happens *after* closing the window that is running in the thread.

Also modal windows running in the original thread still block the secondary window the one created by the swingworker... I was expecting it not to block that thread. Am I doing something wrong still? or is that expected behavior?

-Tad
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the next–to–last paragraph in the Dialog api general remarks section for the affect of a modal dialog.
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess it is supposed to block all threads on that jvm then? Its not really a concern. I just thought maybe it meant I was implementing swingworker incorrectly, but I guess its still behaving properly in that regards.

Now if I could just figure out why no windows will repaint properly after closing the frame thats running in the swingworker thread.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!