• Post Reply Bookmark Topic Watch Topic
  • New Topic

Forcing pack in mouse click event  RSS feed

 
Janis Derby
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a sqlj file that selects about 40 different counts on tables and views and calls several different stored procedures. I also have a JFrame that has a textField for each count I need to do. When I hit the go button, I call these different methods and assign the count to the proper text field.
My problem is that this can take several minutes and I would like to know where in the counts/procedure the program is. I have the textfields gray to start out with, and a status bar. I would like the textfields to turn white and show the number of counts as well as the label in the status bar to show which count/procedure it is currently doing.
I have all the method calls in the ButtonActionPerformed method. I have called pack(), repaint(), validate() on the JFrame and even on the JPanel that the textfields sit on and nothing makes them refresh until all the counts/procedures are called and the ButtonActionPerformed returns.
Is there any way to make the textfields and label refresh during the ButtonActionPerformed method?
 
raj madhuram
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The problem is that you are doing it within the event dispatching thread. All refresh will happen only when the control is relinquished.
To solve your problem, you need to perform those tasks in a background thread.
This might be helpful:
http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html
Regards,
Raj
 
Janis Derby
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks! That's what I needed.
One more question..
If you have a method that takes a parameter and uses it in an anonymous class it must be declared as final. Why?


-jd
 
raj madhuram
Ranch Hand
Posts: 71
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!