• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

FocusListener

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am writing an applet where I want to tab to the next textfield when the user finishes entering text and hits the enter key. I am implementing FocusListener and KeyListener to do this, but I am confused about how exactly to determine whether the user has hit the "enter" key on the keyboard. Do I write code like if (source == enter), or is there some particular code for the enter key on the keyboard?
 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A text field generates ActionEvent when it receives the enter key. You need to implement an action listener to process it.
Hope this helps
 
Jade Davidson
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using an Action Listener. I am implementing all three of them -- ActionListener, KeyListener, and FocusListener. Should I just implement ActionListener to listen for the enter key? I thought you were supposed to use KeyListener for events from the keyboard.
 
Shivaji Marathe
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to implement and use ActionListener for the Enter key in a text field.
Check this out
http://java.sun.com/j2se/1.3/docs/api/index.html

Hope this helps
 
reply
    Bookmark Topic Watch Topic
  • New Topic