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
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).]
Joined: Dec 06, 2000
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.