Problems repainting a frame...

Hi there,

I have a GUI which as part of its operation calls a method that does some fairly intesive JDBC work (lots of adds and updates) which takes roughly 2 minutes...

During this time, if I click away from the UI, when I click back, it fails to re-draw (giving the user the impression it has crashed)

I tried passing a reference of the frame to the method performing the operations, and calling repaint after each operation to no avail...

I also tried using a progress bar (also passing a reference to the bar to the jdbc method, and again no luck)

Any idea what is happening and how i could fix it? Do i need to get threads happening for this?

Thanks a lot,

Nash.

[731 byte] By [nash_tr] at [2007-9-26 1:37:25]
# 1
try thisyourFrame.doLayout();yourFrame.validate();
sasivarnan at 2007-6-29 2:24:09 > top of Java-index,Archived Forums,Swing...
# 2

>>> Do i need to get threads happening for this?

Yes. If you have to do something lengthy, do it in a seperate thread.

the reason is: swing runs in a single thread for painting

and eventhandling. Since your method is part of the eventhandling swing waits for it to return before doing anything else (like reacting on your repaint calls)

Spieler

spieler at 2007-6-29 2:24:09 > top of Java-index,Archived Forums,Swing...
# 3

Yes, normally you receive some event on the AWT Event thread that starts your action. In the event handling method start a separate thread to perform the lengthy task. When you have to update the UI after the task is performed use SwingUtilities.invokeLater or .invokeAndWait.

Kurta

h230561 at 2007-6-29 2:24:09 > top of Java-index,Archived Forums,Swing...
# 4
run that JDBC call in a separate thread and when u get the results urFrame.validate();urFrame.repaint();I think this will solve ur problem
dingarim at 2007-6-29 2:24:09 > top of Java-index,Archived Forums,Swing...
# 5

Have a look at this

http://forum.java.sun.com/thread.jsp?forum=57&thread=147671

I had the same problems:

IM just running a test with a ResultSet-Size of 100000 each row = 128 Byte. ( on W2K )

With this code the textfields are updated regulary but the underlying GUI will take some time. Give JAva and the OS a chance

Hanns

HannsWeil at 2007-6-29 2:24:09 > top of Java-index,Archived Forums,Swing...
# 6
Thanks guys,It's all werkin just fine now.Much appreciated.
nash_tr at 2007-6-29 2:24:09 > top of Java-index,Archived Forums,Swing...
# 7
And what did You promise, when posting Your problem ?
HannsWeil at 2007-6-29 2:24:09 > top of Java-index,Archived Forums,Swing...