Results 1 to 8 of 8
- 04-14-2009, 09:50 PM #1
[SOLVED] Key listener, unsure abt the tab key
I have a key listener set up so that if the users tabs across to the field then the contents of the field can be cleared, however I want it to work that if the TAB key is pressed then as soon as the cursor goes to that cell then the textfield is cleared.
I have it set so that if you navigate the form via mouse then it will clear the cell but cannot seem to get it right with the keylistener.
for a start how do you express the tab key?
- 04-14-2009, 10:00 PM #2
To be a little clearer, I am wanting a text field to clear on the cursor entering by the press of the tab key.
- 04-14-2009, 10:41 PM #3
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5
To check if the tabkey is pressed:
That should work, I think.Java Code:public void keyPressed(keyEvent e) { if (e.getKeyCode() == KeyEvent.VK_TAB) { // code }I die a little on the inside...
Every time I get shot.
- 04-14-2009, 10:53 PM #4
Thanks but that was similar to what I had and only lets me add 1 charector.
can someone tell me what I should be looking for, I am trying to text field on entry from the tab key?
thanks
-
You might not want to use key listeners here. Instead either use key bindings or focus listeners.
- 04-14-2009, 11:18 PM #6
so just to make sure i should be looking at focusGained?
- 04-14-2009, 11:55 PM #7
Thanks for the help, managed to get it working
Java Code:private void txtJdateFocusGained(java.awt.event.FocusEvent evt) { If ( isEnabled() == false); txtJdate.setText("");
- 04-16-2009, 05:49 AM #8
Continuing on from this, there is a help button on my application, you can obviously access help by click however I am looking at accessing it by pressing f1.
This will be a keyEvent however can u just confirm that this has to be in public class or should i be able to use in private?
Thanks in advance
Similar Threads
-
#key listener problem
By mij1_7 in forum New To JavaReplies: 2Last Post: 02-14-2009, 09:02 PM -
Listener for print job
By pjmorce in forum Advanced JavaReplies: 1Last Post: 11-14-2008, 08:02 AM -
Regarding Listener
By adeeb in forum AWT / SwingReplies: 2Last Post: 06-20-2008, 11:07 PM -
Regarding Listener
By adeeb in forum AWT / SwingReplies: 2Last Post: 06-10-2008, 02:00 AM -
Listener for SWT event
By Java Tip in forum Java TipReplies: 0Last Post: 01-08-2008, 09:04 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks