Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

tabbing and enter key for JDK1.1 applet

Posted on 2001-06-19
2
Medium Priority
?
180 Views
Last Modified: 2010-03-31
Hi
I have developed a java(JDK1.1) applet that uses TextFields and Buttons to obtain input from the user.  I would like to be able to set up the ability for
the user to "Tab" and "Enter key" through the fields.
Any help would be appreciated.
0
Comment
Question by:semion50
  • 2
2 Comments
 
LVL 9

Expert Comment

by:Ovi
ID: 6209278
add an KeyListener to thetext field and process there all the key events that are performed by the user.
Please give more details about what have you in mind about the behaviuor of the Tab and Enter keys.
0
 
LVL 9

Accepted Solution

by:
Ovi earned 300 total points
ID: 6209287
import java.awt.event.*;

..........................................
myTextField.addKeyListener(new KeyAdapter() {
  public void keyPressed(KeyEvent ke) {
    switch(ke.getKeyCode()) {
      case KeyEvent.VK_ENTER :
         //do your stuff here
         break;
      case KeyEvent.VK_TAB :
         //do your stuff here
         break;
    }
  }
});
.............................................
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question