Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: java menu

  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    200
    Thanks
    27
    Thanked 2 Times in 2 Posts

    java menu

    Hello,

    I am trying to create a menu in Java.

    I have looked at the Java sun website, and aside from their do it in visual studio tutorials, their only lesson on writing menu's doesn't seem to work...or rather I can't get it to work!!

    Does anyone have some simple code I could look at to work this out...

    Just a basic menu...no submenus required.

    Thanks!!

    Nicola

  • #2
    Regular Coder Aradon's Avatar
    Join Date
    Jun 2005
    Location
    USA
    Posts
    734
    Thanks
    0
    Thanked 20 Times in 19 Posts
    Menu for what? A console application? A GUI? What have you written thus far? We wont do it all for you, but we will help you out.

    If you're talking about GUI menus then you want:

    Menu Tutorial

    If you're talking about console applications, then that's just a matter of printing to screen something and taking in user input.

    Code:
    public class menu
    {
    
      public static void main(String args[])
      {
         System.out.println("Menu:");
         System.out.println("1) Do something");
         System.out.println("2) Do Something Else");
         System.out.print("Choice: ");
         
    
        //// use keyboard input to get value
         if(choice.equalsIgnoreCase("1"))
            // do something
      }
    }
    etc. etc.
    "To iterate is human, to recurse divine." -L. Peter Deutsch

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    200
    Thanks
    27
    Thanked 2 Times in 2 Posts
    Hello,

    Thanks for your reply.

    It is for a GUI.

    I now have it working, I hadn't attached the menu items to the menu bar...

    But...I'm struggling with getting FlowLayout to position the menu on the left hand side of the GUI.

    How do I do this?

    Nicola


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •