Computer Science Canada

How to make menu's

Author:  bodbwoii [ Wed Jan 06, 2010 8:32 pm ]
Post subject:  How to make menu's

heyy; java beginner. doing a school project and i need to know ow to make a menu with 8 options
any ideas?

Author:  DemonWasp [ Wed Jan 06, 2010 8:50 pm ]
Post subject:  RE:How to make menu\'s

Text. Output options in some specific order, prefixed by numbers. Ask them to choose the number of their choice. Act on choice.

Exit gracefully when done.

Author:  bodbwoii [ Wed Jan 06, 2010 10:24 pm ]
Post subject:  RE:How to make menu\'s

huh?

Author:  TheGuardian001 [ Wed Jan 06, 2010 11:20 pm ]
Post subject:  Re: How to make menu's

Those were instructions for a text menu, in the console.
1) Output a list of options, which are numbered.
code:

    Please choose an option:
    1) option1
    2) option2
    3) option3
    etc...

2) Receive user input, and react accordingly.
code:

    choice = User_input
    if (choice == 1)
        do stuff for choice 1
    else if (choice == 2)
        do stuff for choice 2
    else if (choice == 3)
        do stuff for choice 3
    etc...
    else
        User is an idiot.


Unless of course you want a non console based menu, in which case you just add an ActionListener to a Button, JButton, or any other awt/swing widget you care to use.


: