This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes Tab Key in JApplet and JtextField Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Tab Key in JApplet and JtextField" Watch "Tab Key in JApplet and JtextField" New topic
Author

Tab Key in JApplet and JtextField

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Ok, I have been struggling with this for a couple of weeks off and on. I asked a similar question 2 weeks ago in the Applet forum and got little to no help. So here goes in the Swing forum:
I have a JApplet with some JTextFields. I am running JDK1.4.1_01 on XP and JRE 1.4.1_01 in IE 6.0.
The tab keys do not work in traversing to the next component. I even went as far as disabling the key traversal and writing my own KeyEvent to handle the tab key. I can't even get it to recognize the fact that I am hitting the tab key. I have a simple Print statement to tell me when I hit TAB and nothing ever prints.
When this is in an Application Form, it works perfectly.
Does anyone know if this is a Bug and if there is a work around? I really need the tab to work.


GenRocket - Experts at Building Test Data
ali rafiq
Ranch Hand

Joined: Jan 09, 2003
Posts: 75
hi
tab at TextFeild dosnt work . its works on TextArea .. if u pressed tab then it will select next button or next event...


if u learn to break the rock .. next day u will be looking to Mountain.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Which is exactly what I want it to do, but it doesn't.
Thought I made that clear in my post.
Thanks for the reply though.
[ January 10, 2003: Message edited by: Gregg Bolinger ]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Well, I have narrowed the problem down to an actual bug in the JVM. Here is a link to it:
Bug Database
According to them, this issue has been fixed. But it hasn't. Also, on a related bug, they say it works fine in j2sdk1.4.2. Must be nice to be able to install a JDK release that isn't available yet and say everything is fixed. That doesn't help people that need it to work now.
The solution is you have to setTraversableCycleRoot(true) on the JApplet root container. Then you have to setFocusable(true) on every component you need to tab to. This is a workaround and does work.
However, there is still a problem. When creating my own KeyListener I was trying to capture the Tab KeyEvent.VK_TAB. This still doesn't work. In doing this, I noticed that hitting ENTER, SPACE, and TAB all give the same KeyEvent Integer of 0 for some reason. So they are not registering themselves correctly or something.
Anyway, just wanted to give an update as to the information I have found our regarding this problem.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tab Key in JApplet and JtextField