java 如何监听用户按下tab建
我想获取用户按下的tab键值,然后去触发一个事件importjava.applet.Applet;importjava.awt.Color;importjava.awt....
我想获取用户按下的tab键值,然后去触发一个事件
import java.applet.Applet;
import java.awt.Color;
import java.awt.HeadlessException;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JButton;
import javax.swing.JPasswordField;
public class Applet1 extends Applet implements KeyListener
{
char[] keyValue = null;//new char[1024];
int keyLen = 0;
JButton jkeyboard = new JButton();
JPasswordField jpassword = new JPasswordField();
public Applet1() throws HeadlessException
{
super();
}
public void init()
{
this.setBackground(Color.white);
this.setLayout(null);
jpassword.setText("");
jpassword.setBounds(new Rectangle(0, 0, 179, 22));
jpassword.addKeyListener(this);
this.add(jpassword, null);
}
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
System.out.println(keyCode);
}
public void keyReleased(KeyEvent e) {
}
public void keyTyped(KeyEvent e) {
}
}
现在这代码能监听除了tab以外的其他字符的值,怎样才能让tab触发键盘监听事件,急求 展开
import java.applet.Applet;
import java.awt.Color;
import java.awt.HeadlessException;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JButton;
import javax.swing.JPasswordField;
public class Applet1 extends Applet implements KeyListener
{
char[] keyValue = null;//new char[1024];
int keyLen = 0;
JButton jkeyboard = new JButton();
JPasswordField jpassword = new JPasswordField();
public Applet1() throws HeadlessException
{
super();
}
public void init()
{
this.setBackground(Color.white);
this.setLayout(null);
jpassword.setText("");
jpassword.setBounds(new Rectangle(0, 0, 179, 22));
jpassword.addKeyListener(this);
this.add(jpassword, null);
}
public void keyPressed(KeyEvent e) {
int keyCode = e.getKeyCode();
System.out.println(keyCode);
}
public void keyReleased(KeyEvent e) {
}
public void keyTyped(KeyEvent e) {
}
}
现在这代码能监听除了tab以外的其他字符的值,怎样才能让tab触发键盘监听事件,急求 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询