Handling a main menu

hi All!
I have a general question for handling a main menu.
so this is the case:
I have a class extending a JFrame called MainMenuFrame. It contains a MainMenuPanel.
i have another JFrame called GameFrame, and this is for the new game class.
the MainMenuPanel is where all the main menu code takes place and there i have 3 buttons.
Now, i have a variable called selection. it checks which button was selecte and get a value accordingly.
my question is where i should handle the selection. already inside the MainMenuPanel or in the MainMenuFrame?
(when i get a new game selection i want to setVisible(false) the mainMenuFrame and setvisible(true) the GameFrame).
Thanks

I would put the selection variable in main. When it finds that New Game is selected it calls a static method which goes something like:
newGameSelected(GameFrame g, MainMenuFrame m){
    m.setVisible(false);
    g.setVisible(true);
}

Similar Messages

  • Is there a way of just changing the text to the main menu..but not the submenus?

    Is there a way of just changing the text to the main
    menu..but not the submenus?
    Also i have looked at in the browser and when i glide over
    the menu catergories or click on them they dont show the
    submenu...what can i do to solve this?

    Does the example described at
    http://labs.adobe.com/technologies/spry/articles/menu_bar/index.html
    work for you?
    What are you doing that's different from the example?
    When you say you just want to change the text of the main
    menu without changing the submenus, do you mean you want to do so
    dynamically, at some later stage after the page has loaded?
    If so, you could try retrieving the main menu elements you
    want to update from the DOM and updating them from your script's
    event handler for whatever event it is that you want to update them
    in response to. This presumes the widget will detect this and
    update appropriately, which I can't say for sure since I haven't
    actually tried it.
    Hope that helps!
    Rob

  • How to add event handling for a menu?

    hi,
    I have created a menu and few mneu items.
    for eachmenu itme , i did event handling and it is workign fine.
    it was like this
    menuItem = new JMenuItem("Exit",KeyEvent.VK_X);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK));
    menuItem.addActionListener(this);
    menu.add(menuItem);
         public void actionPerformed(ActionEvent e)
    JMenuItem source = (JMenuItem)(e.getSource());
    String s = "Action event detected. Event source: " + source.getText();
    System.out.println(s);     
    public void itemStateChanged(ItemEvent e)
    JMenuItem source = (JMenuItem)(e.getSource());
    String s = "Item event detected. Event source: " + source.getText();
    System.out.println(s);
    now int he second menu i don't have any menu item and i want to do the event handling for the menu itself. any ideas how to do it. following is the code for the menu
    //Build the second menu.
    menu2 = new JMenu("Options");
    menu2.setMnemonic(KeyEvent.VK_O);
    menuBar.add(menu2);
    menu2.addActionListener(this);     //this does nto work

    You were on the right track. However, selecting a menu is different from selecting a menu item. MenuItem chucks an ActionEvent and Menu will send an ItemEvent.
    If you pile all action output to one actionPerformed method then be careful of your assumptions on what the source type will be. If by any chance the Menu has sent an ActinoEvent then your code will have caused a ClassCastException.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MenuTest implements ActionListener, ItemListener {
        JMenuItem menuItem;
        JMenu menu1, menu2;
        JMenuBar menubar;
        JFrame frame;
        public MenuTest() {
            frame = new JFrame("MenuTest");
            frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
            menubar = new JMenuBar();
            frame.setJMenuBar(menubar);
            menu1 = new JMenu("File");
            menu1.setMnemonic(KeyEvent.VK_F);
            menuItem = new JMenuItem("Exit",KeyEvent.VK_X);
            menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.ALT_MASK));
            menuItem.addActionListener(this);
            menu1.addItemListener(this);
            menu1.add(menuItem);
            menubar.add(menu1);
            //Build the second menu.
            menu2 = new JMenu("Options");
            menu2.setMnemonic(KeyEvent.VK_O);
            menu2.addActionListener(this); //this does not work
            menu2.addItemListener(this); // use this instead
            menubar.add(menu2);
            JPanel panel = new JPanel();
            panel.setPreferredSize(new Dimension(100,100));
            frame.getContentPane().add(panel);
            frame.pack();
            frame.show();
        public void actionPerformed(ActionEvent e)
            String s = "Action event detected. Event source: " + e.getSource();
            System.out.println(s);
        public void itemStateChanged(ItemEvent e)
            String s = "Item event detected. Event source: " + e.getSource();
            System.out.println(s);
        public static void main(String[] args) {
            new MenuTest();
    }

  • Image for add-on in main menu.

    Dear All,
    I am facing a problem in loading the image for my add-on. when i run the source file the image is displayed in the main menu. But after converting the source file to ARD format the image is not getting displayed.Pls suggest some solution,
    Regards,
    Anand

    Hello
    A i am suggesting to use the following code to make sure that the image of the Menu is on the Startup directory...
    So
            oMenus = sbo_application.Menus
            Dim oCreationPackage As SAPbouiCOM.MenuCreationParams
            oCreationPackage = sbo_application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_MenuCreationParams)
            oMenuItem = sbo_application.Menus.Item("43520") 'moudles'
            Dim sFileName As String = IO.Directory.GetParent(System.Windows.Forms.Application.StartupPath()).ToString & "CFL.BMP"
            If IO.File.Exists(sFileName) = False Then
                sbo_application.MessageBox(String.Format("The Image {0} does not exists for the menu!", sFileName))
            End If
            ' Creation parameters
            oCreationPackage.Type = SAPbouiCOM.BoMenuType.mt_POPUP
            oCreationPackage.UniqueID = "SM_DMID"
            oCreationPackage.String = "Operations"
            oCreationPackage.Image = sFileName
            oCreationPackage.Position = 4
            oMenus = oMenuItem.SubMenus
            Try ' If the manu already exists this code will fail
                oMenus.AddEx(oCreationPackage)
            Catch er As Exception ' Error Handling
                sbo_application.MessageBox(er.Message)
            End Try
    Regards,
    J.
    Edited by: János Nagy on Nov 16, 2009 9:07 AM

  • Linuxrc "main menu"

    Hello again,
    For various reasons, sometimes when PXE booting, the "root" archive fails to
    download. That's OK, that's not the problem I'm trying to solve.
    The problem is that when this happens, the boot process automatically
    launches something I don't want. Its title bar starts with "linuxrc v1.6",
    the screen is largely blue, but it has a gray menu popped up in the middle
    of it, titled "Main Menu" which includes items like:
    Settings
    System Information
    Kernel Modules (Hardware Drivers)
    Start Installation or System
    I don't want this. Ever. My scripting can handle it if the "root" archive
    fails to download, but it can't if this thing launches and prevents the
    system from carrying on into the scripts. The last thing I want is
    something that requires user interaction. So, my question is, how can I
    prevent this thing from ever coming up? Ideally, if the "root" archive
    failed to download, I would like it just to carry on as if it had.
    Thanks,
    Lisa.

    Thanks for the comprehensive and highly specific reply!
    "Marcus Breiden" <[email protected]> wrote in message
    news:[email protected]...
    > On Fri, 15 Dec 2006 15:23:11 GMT, Lisa Nelson wrote:
    >
    > First, the command TFTPTimeout=(seconds) will increase the default timeout
    > from
    > 10 seconds to whatever is needed.
    What is this number supposed to govern? Is it:
    - Number of seconds, total, allowed for attempting to download root?
    - Number of seconds allowed in any given retry attempt?
    - Something else I haven't thought of?
    I ask because it doesn't appear to have any effect whatever value I put
    here.
    > The initrd and linux tftp download is 40
    > seconds, so use this as a guide.
    What variable governs this? I don't see anything in linuxrc.config that
    appears to be setting this value.
    In general, I would very much like to have a list of all the possible
    variables I can set in linuxrc.config. I have found some general
    linuxrc.config documentation pertaining to SuSE installations, but
    annoyingly, the most comprehensive list only gives "typical" variables
    people use. As far as I can tell there isn't a full list anywhere. Neither
    do examples exist for those that are documented. (E.g. I noticed that there
    exists a variable for setting the language and keyboard. They helpfully
    give the sole example of setting it to de_DE. Very nice if you happen to be
    in Germany. What if you are in some other country? No list of other
    possibilities is provided. I'd like one.)
    > Second, you can set the KDBTimeout=(seconds) to automatically
    > input(simulate
    > the enter key) the highlighted item. After a few screens, you will see
    > that
    > it
    > takes the machine automatically to the TFTP server screen. This allows the
    > machine to automatically check the TFTP server again for the boot/root
    > file,
    > download it, and apply any work to do again.
    Through trial and error I have found that you probably mean KBDTimeout.
    I set this to a value of 5 seconds so that I could see what happens.
    When it comes up into that installation menu I get this series of events:
    1. that first installation menu appears; it does indeed apparently press
    enter automatically.
    2. menu "Start Installation or System" appears; it presses enter on "Start
    Installation or Update"
    3. menu "Choose the Source Medium" appears; it presses enter, but on the
    entry "CD-ROM"
    4. (it sends a DHCP request again) it then tries to find the root archive on
    the CD-ROM drive. But of course, I have booted PXE so there is no CD. It
    gives me an error message: "Make sure that CD number 1 is in your drive"
    5. it presses enter again on the entry "CD-ROM". (It again sends a DHCP
    request) This time it gives me an error message: "Unable to mount the
    CD-ROM" (in red)
    It then repeats alternating between these last two error messages for as
    long as I care to leave it.
    In the menu where it is choosing "CD-ROM", "Network" is the second choice in
    the menu, not the first.
    > This will require to unzip the initrd and edit the linuxrc.conf.
    Yes, I'm OK with that. But I think you mean linuxrc.config. Just worth
    mentioning in case anybody besides me ever tries to follow these directions.
    Thanks,
    Lisa.

  • I have a new MacBook(2012). Being a new Mac user, I do not know what to do when Safari doesn't open at all. The icon just bounces up and down and when the cursor is on the top main menu bar it is the spinning rainbow wheel.  Any ideas for help?

    When I try to open safari the icon stats bouncing and then nothing happens other than the cursor turning to a spinning rainbow wheel when it hoovers on the top main menu bar. I have shut down and restart several times. My safari worked yesterday and then today this, but with. I indication of a problem. I can't even get the browser window to open so that I can clear caches or reset anything. When I opened my computer this time I don't even get a bouncing icon. No recognition of selecting the program at all. If I go to spotlight and try to open safari from here I still get no response. Can you help?

    Hi ...
    If you have moved the Safari application from the Applications folder, move it back.
    As far as the cache goes, there's a work around for that when you can't empty the Safari cache from the menu bar.
    Go to    ~/Library/Caches/com.aple.Safari.Cache.db.  Move the Cache.db file to the Trash.
    Try Safari.
    Mac OS X (10.7.2)   <  from your profile
    If that is corrrect, you need to update your system software. Click your Apple menu icon top left in your screen. From the drop down menu click Software
    Update ...
    ~ (Tilde) character represents the Home folder.
    For Lion v10.7x:  To find the Home folder in OS X Lion, open the Finder, hold the Option key, and choose Go > Library

  • Voice memo in main menu

    Recently the voice memo option put itself into my main menu after either a sync or a soft reset. Now I can't get rid of it, since it's not in the extras menu as something to check/uncheck. Do I need to restore my iPod to fix this?

    Hello spartanhooah,
    And welcome to Apple Discussions!
    Have you tried another soft reset of the iPod again? Usually doing so clears up this issue. Otherwise, if you have, then yes, your next step would be to restore the iPod via iTunes.
    B-rock

  • Voice Memo item in main menu

    A Voice Memo item has appeared in main menu and I cannot remove it. When I go to *settings>main menu* no such item is listed so I cannot deselect it. Any ideas appreciated...

    i'm having the same problem and wondering the same thing....

  • I am trying to make a main menu for my project but I don't know where IDVD is located?

    I am trying to make a main menu but I read some info. and said I have to do it through IDVD and I tried it but can not find IDVD anywhere so I wanted to know if I have to purchase it or something and I also wanted to know how to create a main menu?

    depends on how old your Mac is ...
    newer machines do not come along with a pre-installed  iDVD (.. and iWeb ..) anymore; you have to purchase a boxed version of iLife11.
    if somehow iDVD is installed on your Mac, you should find it in your Apps-folder
    (or use Spotlight, search for iDVD) ...-

  • Can't access the "Apple" icon in upper main menu to shutdown my MacBook Pro running 10.6.8!  Also can't open a new finder window and main menus such as File and Edit are sluggish to open or don't open at all.  Doesn't happen each time I attempt to shutdow

    Can't access the "Apple" icon in upper main menu to shutdown my MacBook Pro running 10.6.8!  Also can't open a new finder window and main menus such as File and Edit are sluggish to open or don't open at all.  Doesn't happen each time I attempt to shutdowCan't

    There are some keyboard commands (shortcuts) you can use instead of having to go to the Apple menu -
    Control-Eject          This brings up the Restart-Sleep-Cancel-Shutdown window.
    Command-Option-Eject          This puts the machine to sleep.
    Command-Control-Eject          This closes all apps and restarts the machine.
    Command-Option-Control-Eject          This closes all apps and shuts the machine down.

  • Page Forward & Reverse buttons do not work & are "grayed-out" after upgrading to, as is the Main-Menu Items such as File-Edit-view etc...

    After upgrading to Firefox 3.6.12 all functionality appeared to be intact. Then after a few days it lost the ability to "page forward" or to "page back" and are "grayed-out". Additionally, the Main menu items such as File, Edit, View, History, Bookmarks, Tools & Help are also grayed-out and non-functioning.
    Also, the "Search Window" does not search, Web Searches need to be performed from within the URL window instead, for some crazy reason. If the URL window is blank when I enter a search into the actual search window the following appears in the URL window, "Search Bookmarks and History", which makes no sense.
    I have noticed similar complaints in this Forum in the past but I have not seen any posted resolution to these issues. Is there a solution?

    Create a new profile as a test to check if your current profile is causing the problems.<br />
    See [[Basic Troubleshooting#Make_a_new_profile|Basic Troubleshooting&#58; Make a new profile]]
    There may be extensions and plugins installed by default in a new profile, so check that in "Tools > Add-ons > Extensions & Plugins"
    If that new profile works then you can transfer some files from the old profile to that new profile (be careful not to copy corrupted files)
    See http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox

  • Unable to view A/R Invoice form and Main menu

    Dear Experts,
    I am using 2007 A pl 30. I did allocate the manager for the Professional User, SAP Addons, SDK Tools. When i try to open the A/R invoice form, it is not showing on screen but then it is available in the window drop down menu. Also, the main menu is not showing. The other forms are viewable.
    Thank you in advance.
    Manuel

    Click on A/R Invoice and Select Windows - Cascade to bring the screen down to normal.

  • How to block the Form Settings for Main Menu to use ONLY "My Menu"?

    Hi everyone:
    Our customer wants to define an User Menu (My Menu) for each B1 user within the company and restrict the Modules at main menuu2026
    How can I block the Form Settings for the Main Menu?... It is possible to give an user Only access to My Menu and denied Authorization to the Modules?. 
    I appreciate your help!!. Thanks very much
    Claudia Gutiérrez

    Hi,
    'My Menu' refers to the third tab on the Main Menu, and the
    authorization of 'Organize My Menu' works as below:
    - Full Authorization: Allows the user to access the Organize User Menu
      window (Tools -> User Menu -> Organize) and customize the menu.
    - No Authorization: The user cannot open this window.
    Check the Note  [1062635|https://websmp130.sap-ag.de/sap(bD1odSZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=1062635] if you are looking for it.
    Regards,
    Jitin
    SAP Business One Forum Team

  • Is there any way to create or move around folders on the main menu?

    For example, I know how to add things like Clock, and take out things like pictures.. but is there a way I could create another option to put notes or photos in? Like a new folder on the main menu that you could go into and it would have maybe my photos, notes, and a calendar or something like that.

    You should be able to create and edit playlists on iOS devices and in iTunes.  Probably much quicker and easier on the computer, and I believe smart playlists can only be created in iTunes.

  • Create a new folder in sap r/3 main menu

    HI, i want to create a new folder into Material Management Module, this folder contain several transactions.
    What i need to do in order to sucess with this task?
    Thanks.
    Reward Points

    I try to do that, but i can't see the new folder
    The current system is not the original system of the menu
    Changes could be lost in future imports
    Addition remain
    And i choose Change.
    Expand the three in the position on Material Management and i choose insert as subnode and save
    But in the logon to the system (main menu) i cant see my folder
    Thanks

Maybe you are looking for

  • How to show relation attribute on logical model

    Hi. How to show child entity relation attributes on logical model? Entity properties attribute list contains relation attributes, LM dont show they. I have model with several subviews. I need to show some entity without related entities but need to s

  • Regarding SRM busniess process flow

    Hi i am having a book of SRM 201 and start learning and enhancing my skills,i feel sometimes lost while reading and practiing the same in IDES as i am not aware about the business process of SRM completely.Can all of you experts please explain what a

  • Reset password for Wireless routers

    How to reset the password for wireless routers? Do I re-setup again? I lost my CD and manual, what can i do?

  • Cannot access Printer Properties

    I have quite a few users who are having a problem when they try to print from FF 22.0. When they try to print a webpage, email, document, etc. and go into the Properties for the printer to change it from Letter to Legal, or Legal to Letter, the item

  • Can I scan 110 film negatives on the canoscan 9000f?

    I am contemplating buying the canoscan 9000f, but I will need to be able to scan 110mm film format. Can I do this on the canoscan 9000f? I have seen an adapter for that film size on ebay and amazon (oddly enough, cannot find it on Canon), but the pri