Java Switch sequence help

Mugiwara

Active member
Legendary
Joined
Apr 25, 2008
Messages
11,625
Kin
24💸
Kumi
0💴
Trait Points
0⚔️
Awards
I have a long switch sequence with 39 cases. I also have a JMenuItem: "Go Back", which switches me to another JPanel, but once I start the switch sequence, I can no longer use that button. Any idea how I can fix that?


nvm, i'm an idiot. Should just have put "else{}" around the switch.
 
Last edited:

SenjuTobirama

Member
Joined
Apr 8, 2010
Messages
29
Kin
0💸
Kumi
0💴
Trait Points
0⚔️
from what i can see is the "go back" is only created in that first instance and if it is true in that instance it just continues, it looks like you need something to keep creating that button, have you tried a while loop?
 

Mugiwara

Active member
Legendary
Joined
Apr 25, 2008
Messages
11,625
Kin
24💸
Kumi
0💴
Trait Points
0⚔️
Awards
from what i can see is the "go back" is only created in that first instance and if it is true in that instance it just continues, it looks like you need something to keep creating that button, have you tried a while loop?
The Go Back button works before I start the sequence. As I've said, I have 39 cases. I need a way to stop the sequence from outside the switch loop. I need to give the user the ability to back from the program whenever the user wishes too, not only before he starts the sequence and after the sequence is finished.

I need that button to override whatever command the switch loop gives.
 
Last edited:

Mugiwara

Active member
Legendary
Joined
Apr 25, 2008
Messages
11,625
Kin
24💸
Kumi
0💴
Trait Points
0⚔️
Awards
Im glad you got the code to work :) i hate when im programming and there is just one little thing that isnt working right.
Especially when the answer to fixing that problem is the simplest in the world.

Removed the code so that I wouldn't have to answer for plagiarism and shit on the project. (Even though its only 20 lines out of 1000 in that program I link, still :p ) Just delivered in the project. 5 "games", 4 menus(1 main menu, leading into 3 subjects(math, geography, english, each of the subject had 1-2 programs/games each)), 1 main method. In total 10 Java files. Over 6000 lines of code :p Hoping for a good grade xd
 
Top