This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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: 37900
    
  22
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: 37900
    
  22
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.
 
Similar Threads
Multiple updates
Yes! Passed! 388/400
How to fetch Date Field from excel sheet in Java
jlabel problem
Panel to acts like Button