数字也输入名称文本字段,此代码无法正常工作。请举例帮助我。
Name_text.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
if(e.getKeyChar()>='0'&& e.getKeyChar()<='9'|| e.getKeyChar()>=33&& e.getKeyChar()<=47|| e.getKeyChar()>=58&& e.getKeyChar()<=64 || e.getKeyChar()>=91&& e.getKeyChar()<=96 || e.getKeyChar()>=123&& e.getKeyChar()<=127 ){
JOptionPane.showMessageDialog(null, "enter characters only");
}
}
});