|
|
Re: ending a loop with input?
|
Posted: May 8, 2006 10:45 PM
|
|
You need a condition boolean enterPressed = false; at the beginning of the loop. You now have two possibilities, but I'm afraid I cannot tell you how to implement them (have to read the API myself). Just to give you an idea.
1. There is a key buffer for all typed keys. At the end of the loop check if this buffer is empty. Otherwise read it and check if someone pressed Enter.
2. Swing supports a KeyEvent which is launched at every key pressed. Maybe you can use the same mechanics for your text interface.
In both cases just set enterPressed = true, if the Enter key was typed.
|
|