Reputation: 1
So what I've been attempting to do is essentially have it set to when the enter key is pressed on my JFrame in java it detects it so I can do an action like start a game by switching to the next screen. So I was wondering if anyone could help me figure out how to do this in particular. Just being able to have something that constantly checks to see if the Enter Key has been pressed on the JFrame
Upvotes: 0
Views: 286
Reputation: 324207
have it set to when the enter key is pressed on my JFrame in java it detects it so I can do an action like start a game by switching to the next screen.
How do people know to use the Enter key?
Typically you would have a button like "Start Game" for the user to click.
You can easily make this the default button by using:
frame.getRootPane().setDefaultButton( startGameButton );
Now the user will be able to either:
Upvotes: 1