Saturday 15 May 2010

java - How to give JFrame initial focus -


What is the method that allows you to use JFrame without first clicking it ? I have a game, but to go with WASD I have to click the frame for the first time when the app is running.

New Games ();

I have this:

game.frame.setResizable (wrong); Game.frame.setTitle (Game.title); Game.frame.add (game); Game.frame.pack (); Game.frame.setDefaultCloseOperation (WindowConstants.EXIT_ON_CLOSE); Game.frame.setLocationRelativeTo (zero); Game.frame.setVisible (true);

me game.frame.requestFocus (); Where is the post-text? Itemprop = "text">

This is the requestFocus () method, which puts the focus on that component. Which it is called (JFrame in this case).

No comments:

Post a Comment