Wednesday, 15 January 2014

java - How to stop JOptionPane from choosing last case? -



java - How to stop JOptionPane from choosing last case? -

so here case create long code short.

let's say, have joptionpane 3 buttons.

boolean loopgameinterface = true; while(loopgameinterface){ int choosegame = joptionepane........ switch(choosegame) { case 0: case 1: case 2: system.exit(0); } }

so problem is, when click (example) sec button, goes case 1. that's fine. when code within case 1 executed, goes straight case 2 , exit program, instead of looping gameinterface?

you need add together break; @ end of each case. true switch statements way, not when using joptionpane

java loops switch-statement case

No comments:

Post a Comment