我让我的游戏不需要鼠标就能运行,所以使用指针不是一个选择。当玩家失败时,将显示最高分菜单。
这是我的代码。
这是我的代码。
highScore=new MyTextField("Your Name");
highScore.addKeyListener(this);
highScore.setFont(font);
highScore.requestFocusInWindow();
我已经尝试过
highScore.setFocusable(true);
highScore.requestFocusInWindow();
highScore.requestFocus(true);
highScore.requestFocus();
但是我的JTextField
仍未获得焦点。
如何让它获得焦点?