• Post Reply Bookmark Topic Watch Topic
  • New Topic

Label not repainting within event handler

 
Chrissy Simpson
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey all. I have the following code:

My problem is that the statusLabel is not repainted before the search call is made. Therefore, the user never sees the "Searching..." text. Does anyone know how I can modify this code to get the desired behaviour of setting the status label to "Searching..." as the search executes and then setting the status label to reflect the results when the search is complete? Thanks...
 
Zhao Fu Qiang
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try following code:
Runnable runner = new Runnable() {
Object[] newData = search(); remoteStatusLabel.setText("Search Complete [" + newData.length + " results found]");
};
SwingUtilities.invokeLater(runner);
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"zfq" -

Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it here.

Thanks! and welcome to the JavaRanch!
 
Chrissy Simpson
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked! thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!