• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to disable components

 
Jackie Davis
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I disable AWT checkboxes and scrollbars? I can't seem to find any relevant API.

for example in pesudo code:

 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The java.awt.Component class -which all AWT elements extend- has the "setEnabled(boolean)" method, which does exactly that.
 
Jackie Davis
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for that!

Another question, if I have sent a thread to sleep for 10secs.

Thread.sleep(10000)

How do I break out of the sleep if I un-check a checkbox?



Not sure if I use the .notify() method or where to use it.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to hang on to a reference to the thread in question, and then call thread.interrupt(). You should only do this with threads you have created yourself, not with AWT threads that call your paint methods or event handlers. The article referenced in the javadocs for several Thread methods (e.g. Thread.sleep) talks about thread handling in the context of AWT events; that should be helpful reading for what you're doing.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!