File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

disable keyboard for Textfield

 
Vinod Venugopal
Ranch Hand
Posts: 148
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a JTextField which shows a string value based on some conditions, now I want it to function in such a way that when a textfield gets focus it should not receive any keyboard events, in other words I want to disable any sort of listeners for the textfield. Is this possible? I have tried using removeXYZListener() etc, but still I'm able to use the spacebar/delete & in this way change the text.Pls help.
Vinod
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
Hi Vinod,
There is two ways you can choose from:
(1) yourTextField.setEditable( false );
Sets the specified boolean to indicate whether or not this TextComponent should be editable. A PropertyChange event ("editable") is fired when the state is changed.
(2) yourTextField.setEnabled( false );
Sets whether or not this component is enabled. A component that is enabled may respond to user input, while a component that is not enabled cannot respond to user input. Some components may alter their visual representation when they are disabled in order to provide feedback to the user that they cannot take input.
let me know if this was some help
thanks
Yoel Stern

------------------
Sun Certified Programmer for JAVA 2 Platform
[This message has been edited by yoel stern (edited August 14, 2001).]
 
Vinod Venugopal
Ranch Hand
Posts: 148
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx a lot Yoel,
I was actually thinkin around the same lines & did it, I wanted to use some of the removeListener methods to do it , or maybe disableEvents() but somehow they didnt work (do you know how to do it?), so then I had to resort to the old way of disabling the fields.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic