How to Set Focus on JTextField?

后端 未结 10 1889
感情败类
感情败类 2020-11-30 07:34

I make my game run without mouse so using pointer is not a choice. High Score menu will show when player lose.

this is my code

    highScore=new MyTe         


        
10条回答
  •  情深已故
    2020-11-30 08:11

    This code mouse cursor “jtextfield” “Jcombobox” location focused

     try {
         Robot  robot = new Robot();
            int x = Jtextfield.getLocationOnScreen().x;
            int y=  Jtextfield.getLocationOnScreen().y;
           JOptionPane.showMessageDialog(null, x+"x< - y>"+y);// for I location see
            robot.mouseMove(x, y);
        } catch (AWTException ex) { 
            ex.printStackTrace();
        } 
    

提交回复
热议问题