This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Hi Bowe, If you are using a menu which has menu items (menu = file, menu item= new) you can add the action listener to the menu items and in the actionPerformed() you can check which menu item was clicked and do what you want to do. Hope this helps.
SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)
Joined: Dec 09, 2004
It is actually an application that has a menu (no GUI). That is my big problem - I have the application so that it prints out the menu, but now I need the user selection to tell the program what to do from there. Thanks.
One thing we all found disappointing the first time is that you can't get a single keystroke menu choice from the user. You have to make the user press Enter to get anything. Reading from the console is just annoyingly fussy enough that you might want to make a little utility class to hold some reusable code. By way of example, think about how you'd make this work:
If you're in JDK 5 see if you can use Scanner instead of BufferedReader. And let me know the answer!
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi