I have being trying to under stand a simple menu, and I have read alot of text on this, but I'm still confused.
I have found and re worked a simple menu and I need to find out how to make it work.
When you click on New how does it know where to go.
I'm working a project when a client click on "New" they will be prompt to enter a persons ID number, thou a Scanner. The scanner will check to see if the id number is listed or not. Info or data is stored in Arraylist.
Any advice or direction on how to do this would be great.
thanks
nomad
Expand|Select|Wrap|Line Numbers
- package company;
- import java.awt.*;
- import javax.swing.*;
- import java.awt.event.*;
- /**
- * @param args
- */
- // TODO Auto-generated method stub
- /*
- <APPLET
- CODE = menu.class
- WIDTH = 350
- HEIGHT = 280 >
- </APPLET>
- */
- public class Sample_menu extends JApplet implements ActionListener
- {
- public void init()
- {
- JMenuBar jmenubar = new JMenuBar();
- JMenu jmenu1 = new JMenu("File");
- JMenuItem jmenuitem1 = new JMenuItem("New..."),
- jmenuitem2 = new JMenuItem("Find.."),
- jmenuitem3 = new JMenuItem("Exit");
- jmenu1.add(jmenuitem1);
- jmenu1.add(jmenuitem2);
- jmenu1.addSeparator();
- jmenu1.add(jmenuitem3);
- jmenuitem1.setActionCommand("You selected New");
- jmenuitem2.setActionCommand("You selected Find");
- jmenuitem1.addActionListener(this); //
- jmenuitem2.addActionListener(this);
- jmenubar.add(jmenu1);
- setJMenuBar(jmenubar);
- }
- public void actionPerformed(ActionEvent e)
- {
- JMenuItem jmenuitem = (JMenuItem)e.getSource();
- showStatus(jmenuitem.getActionCommand());
- }
- }
- kbd = new Scanner(System.in);
- System.out.print("\nPlease press Enter afer each response");
- System.out.print("Enter ther Employee ID Number");
- abc_flag = kbd.nextInt();