Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do i block user inputs till swing worker terminates ?

 
raj varma
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do i use JProgress bar to show some work is going on till swing worker thread finishes, so that i can bock further users inputs ?
Please Help
 
Howard Zhao
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Suppose curFrame is your current working JFrame and myComp is the component whcih has focus.
Right before your worker starts, do
curFrame.getGlassPane().setVisible(true); //block mouse input
curFrame.getGlassPane().requestFocus(); //block keyboard input
After the worker finishes, do
curFrame.getGlassPane().setVisible(false);
myComp.requestFocus(); //set focus back to get keyboard input.
Howard
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic