• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in setting text to jlabel while another action is going on.

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have jframe which is having two panels.first panel the textbox and button is there and in second panel jabel is there.when i am updating text in the textbox jlabel text should be "updating....." .After completion of update operation jlabel text should be "updated successfully".But while update is ggoing on the text which i have set to jlabel is not appearing in jlabel.After completion of update operation it is showing text "updated successfully".

button.addActionListener(this);
public void actionPerformed(ActionEvent ae)
{
String command = ae.getActionCommand();
if(command.equals("Update"))
{
showStatus.setText("updating.....");
boolean result=handleupdate();
if(rresult)
{
showStatus.setText("updated successfully..");
}
else
{
showStatus.setText("updation failed...");
}
}
}




Please help me to resove this.Thanks in advance
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like a threading problem. You know that all use of Swing components must be in the Event Despatch Thread? If you have another action going on which is time‑consuming, you might do well to start another thread. Look for the SwingWorker class as one way to do that.
 
Campbell Ritchie
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But do you want it to say “updated” before the update is completed? Look up progress bars.
 
reply
    Bookmark Topic Watch Topic
  • New Topic