1 posts in topic
Flat View  Flat View

Posted By:   Almas_Khan
Posted On:   Wednesday, April 18, 2001 10:51 PM

I have an uneditable JTextBox which displays numbers on the click of a button or a keyboard event for that button. Eg, if I click on the button named 4 or if I type 4, it displays 4 in the JTextBox. I want to add keyboard events for the backspace and enter key without providing 2 seperate buttons. Like, if I press backspace or delete on the keyboard, it should do the functionality of backspace and if I press enter on the keyboard it should erase all the contents of the JTextbox. How do I do it.

Re: JTextBox

Posted By:   Nidhi_Madan  
Posted On:   Wednesday, April 18, 2001 11:26 PM

Hi Almas,
you can add the KeyListener to that JTextField and then check for the KeyEvents for the backspace and enter key and if the condition is true u can write whatever you want to do with the text field. the KeyCode for both the keys is
VK_BACKSPACE and VK_ENTER. i hope it works for u.if u need the code for it. reply back, i'll mail you.
About | Sitemap | Contact