Computer Science Canada Issue when switching between menus |
Author: | xHoly-Divinity [ Wed Apr 25, 2007 8:45 pm ] | ||||
Post subject: | Issue when switching between menus | ||||
Ok here is the problem: My main program executes my main menu. My main menu returns a value to the main prog indicating when the 'play' button was hit. It works fine until..... Until I enter a new menu. So from my main menu, when I click on say 'options', my main menu is hidden, and then my options menu is executed. When the back button is hit, the options menu gets hidden and it creates a NEW main menu. So now when I click 'play', because it is in essence a new program that was executed, my main program will not receive any input from it. I also tried closing instead of hiding, but it doesn't work. What I need to do is 'reveal' my main menu. I've tried doing this in my main program, and also my menu class. When I do it in the menu class, I have to enter a 'while' loop (which keeps checking when the 'back' button was hit from the other class), but if I do, the other menu will not load.
Help or ideas are much appreciated. Thanks!! ![]() |
Author: | HellblazerX [ Thu Apr 26, 2007 12:59 pm ] | ||
Post subject: | RE:Issue when switching between menus | ||
Why do you have to create a new main menu every time you pressed back? I did something like this for my FP last year, and the way I did it is I had a reference in all my menus to my main program (I'm assuming all your menus are JPanels, and your main program is a JFrame which contains all of it), and whenever I'd click the back button, I have my main program remove my current menu, and readd my main menu. It looked like this:
Content refers to my main program class, and menuPanel is my main menu. |
Author: | xHoly-Divinity [ Thu Apr 26, 2007 5:42 pm ] |
Post subject: | Re: Issue when switching between menus |
Actually.... all my menus are JFrames and are pretty much independent of each other... I will give your way a shot and see how it goes. I'll follow up if I have any other problems. Thanks ![]() |