Have you looked at using key binding instead of key listener?
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Have you tried writing a small program to work out how to use key bindings?
When you understand how it works, you will be able to use the technique in the Sokoban program.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Can you make a small program that compile, executes and shows the problem?
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Please post the code here vs a link.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
We cross posted. See my last post.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
do some action only when enter is pressed
Put the code in the listener that is called when Enter is pressed.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Events like key presses don't work that way. You need to use a listener that is called when the event happens. The code should show a window with a button and then exit to the jvm to await the user pressing the button. When the button is pressed, the event listener is called.
If you want to pause the execution of a method, you might be able to use something like the wait() notify() methods. Call wait() in at the place you want to pause execution and call notify() for that wait() in the listener method.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16