?
Solved

button gets locked until process completes

Posted on 2003-03-24
9
Medium Priority
?
169 Views
Last Modified: 2010-03-31
I am trying to develop a jFrame application but when i click on the button to do some task the button gets stuck with the container and container doesnt provide to do any other task, is there any way out to release the lock and let the process run on the back ground.
0
Comment
Question by:kausiksarkar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 30

Expert Comment

by:Mayank S
ID: 8200885
What is your actionPerformed () method??

Mayank.
0
 
LVL 92

Expert Comment

by:objects
ID: 8200914
You need to do your processing in a new thread.
Swing runs in a single thread so if you block that thread gui updating is blocked.
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 8200919
public void actionPerformed(ActionEvent e)
{
   new Thread(new Runnable() {
      public void run() { doLongProcessing(); }}).start();
}
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 9

Expert Comment

by:yongsing
ID: 8200925
Most likely you are performing the task in the event dispatching thread. That's why the event dispatching thread doesn't get the chance to repaint the button. What you can do is to create a new thread to perform the task.
0
 
LVL 3

Expert Comment

by:zero303
ID: 8201076
This happened to me when i'd accidently done the old inifinite loop lol, it was my first ever Java GUI and like you said the button freezes... It was just waiting to finish the never-ending loop!
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 8201096
Please post your actionPerformed () method so that we can see why its freezing.

Mayank.
0
 

Author Comment

by:kausiksarkar
ID: 8201511
Thanks objects u r really great it works and works very well i have never been any idea like this. Thanks a lot.
0
 

Author Comment

by:kausiksarkar
ID: 8201514
Thanks for this great solution i really shocked to see it works. Thanks a lot man.
0
 
LVL 92

Expert Comment

by:objects
ID: 8206382
No worries, glad it did the trick for you :-)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month9 days, 1 hour left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question