我让我的游戏没有鼠标运行所以使用指针不是一个选择.当玩家输球时,高分菜单会显示.
这是我的代码
highScore=new MyTextField("Your Name");
highScore.addKeyListener(this);
highScore.setFont(font);
highScore.requestFocusInWindow();
Run Code Online (Sandbox Code Playgroud)
我试过了
highScore.setFocusable(true);
highScore.requestFocusInWindow();
highScore.requestFocus(true);
highScore.requestFocus();
Run Code Online (Sandbox Code Playgroud)
但仍然没有把重点放在我的身上JTextField.
如何关注它?