The program should be event driven not spinning in a loop. The code waits for the user to do something (an event) and then reacts to that event. It is not executing in a loop while it is waiting. It has returned to the JVM and waits for the JVM to call a listener when the next event happens.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
having your application perform a task by clicking a button can easily be done by using ActionListener. there are other Listeners that can help you out as well, so no, I'm not saying this solution is 'the one and only'
stultuske
Industrious Poster
4,489 posts since Jan 2007
Reputation Points: 1,377
Solved Threads: 628
Skill Endorsements: 25
well, you add a button to your screen, you add an ActionListener to that button, you implement the actionPerformed method and add your logic in there. I'm sure there are tons of examples on the net an easy google query would bring up.
stultuske
Industrious Poster
4,489 posts since Jan 2007
Reputation Points: 1,377
Solved Threads: 628
Skill Endorsements: 25
no, just check:
if ( gameType != null ){
runYourCode();
}
else{
error("Game type isn't created yet");
}
stultuske
Industrious Poster
4,489 posts since Jan 2007
Reputation Points: 1,377
Solved Threads: 628
Skill Endorsements: 25