Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

processing events  RSS feed

 
Haris Karameh
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am just starting with Swing and hit my first roadblock:
I have a JFrame with a menu and textField.
I want user to click on the menu item which is supposed to execute a
set of methods. The method execution is called from "Action performed" fr the menu item and this works.
e.g
actionPerformed(ActionEvent ae){
method1();
textField.setText("One done");
method2();
textField.setText("Two done");
method3();
textField.setText("");
}

As methods execute longer I added "status" text into the textField.
The problem is I can not see changes.
Being familiar with VB and Delphi, there are methods like DoEvents or Yield which would allow UI to refresh. Is there similar method in Swing which I can call after .setText in order to render UI change immediatelly. If not any pointers how this might be done are appreciated.
TIA,
Haris
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
scroll down to question 3.1

http://www.cs.uu.nl/wais/html/na-dir/computer-lang/java/gui/faq.html
 
Haris Karameh
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael, that did help.
I run over FAQs before but somehow did not notice the suggested one.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!