aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Problem in setting text to jlabel while another action is going on. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem in setting text to jlabel while another action is going on." Watch "Problem in setting text to jlabel while another action is going on." New topic
Author

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

SaiManasa Dasari
Ranch Hand

Joined: Aug 21, 2012
Posts: 32
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
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39409
    
  28
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
Sheriff

Joined: Oct 13, 2005
Posts: 39409
    
  28
But do you want it to say “updated” before the update is completed? Look up progress bars.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in setting text to jlabel while another action is going on.