私は何かを試しましたが、結果が得られませんでした
private void txtNameKeyPressed(java.awt.event.KeyEvent evt) {
String value = txtName.getText();
digitcheck = value;
if ((evt.getKeyCode() >= KeyEvent.VK_1 && evt.getKeyCode() <= KeyEvent.VK_2))
{
txtName.setEditable(true);
//If the Digit in JTextField exceeds two digits JTextField is deactivated
if(maxDigit(1))
{
try {
txtName.setEditable(true);
txtAdd.setEnabled(true);
Robot robot = new Robot();
robot.keyRelease(KeyEvent.VK_TAB);
} catch (AWTException ex) {
Logger.getLogger(Demo.class.getName()).log(Level.SEVERE, null, ex);
}
}
else
{
txtAdd.setEnabled(false);
}
}
else
{
txtAdd.setEnabled(false);
}
}