Java Switch sequence help

Mugiwara

Kage in the Making 👑
Legendary
Joined
Apr 25, 2008
Messages
11,629
Reaction score
1,783
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:

Zawar

Legendary Shinobi 🐸
Supreme
Joined
Apr 23, 2011
Messages
30,406
Reaction score
611
i had this prob then i wrote the button code in both switch cases xD
it worked but code expanded
 

SenjuTobirama

Member
Joined
Apr 8, 2010
Messages
29
Reaction score
4
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

Kage in the Making 👑
Legendary
Joined
Apr 25, 2008
Messages
11,629
Reaction score
1,783
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

Kage in the Making 👑
Legendary
Joined
Apr 25, 2008
Messages
11,629
Reaction score
1,783
then you need to create the button inside the switch, or use exception handling

do you got msn ? :p Got to finish this project today. Just some last bug fixes and such. That button seems to be the only thing I have problem with fixing.
 

SenjuTobirama

Member
Joined
Apr 8, 2010
Messages
29
Reaction score
4
no i dont have msn, but if you create the button inside the switch it should work, just once you hit the default case im not sure what happens
 

Mugiwara

Kage in the Making 👑
Legendary
Joined
Apr 25, 2008
Messages
11,629
Reaction score
1,783
no i dont have msn, but if you create the button inside the switch it should work, just once you hit the default case im not sure what happens

You mean to create the buttons in the switch, or just the actionperformed part of the buttons?
 

Kagutsuchi

Kage in the Making 👑
Legendary
Joined
Sep 28, 2008
Messages
17,636
Reaction score
739
Status
@$$Hole got his code Working :p
Thank you All for your Help xd

~Thread Closed.
 
Last edited:

SenjuTobirama

Member
Joined
Apr 8, 2010
Messages
29
Reaction score
4
Im glad you got the code to work :) i hate when im programming and there is just one little thing that isnt working right.
 

Mugiwara

Kage in the Making 👑
Legendary
Joined
Apr 25, 2008
Messages
11,629
Reaction score
1,783
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