How do i set actionPerformed events on these?

I don;t know how to set up the actionPerformed method for these menuitems. how will iknow whichmenuitem has been pressed?
public MainPage(String LoggedOnUsername, String Password, String sMonth)
throws Exception
super();
this.setLayout(new BorderLayout());
//Create the menu bar.
AppletMenuBar = new JMenuBar();
//setJMenuBar(AppletMenuBar);
//Build the first menu.
menu1 = new JMenu("User");
menu1.setMnemonic(KeyEvent.VK_U);
AppletMenuBar.add(menu1);
// Add menuItems to menu1
menuItem = new JMenuItem("View Profile", KeyEvent.VK_F);
menu1.add(menuItem);
menuItem.addActionListener(this);
menuItem = new JMenuItem("Change Password", KeyEvent.VK_P);
menu1.add(menuItem);
menuItem.addActionListener(this);
menuItem = new JMenuItem("Logout", KeyEvent.VK_L);
menu1.add(menuItem);
menuItem.addActionListener(this);
// Build the second menu
menu2 = new JMenu("Schedule");
menu2.setMnemonic(KeyEvent.VK_S);
AppletMenuBar.add(menu2);
menuItem = new JMenuItem("Calender View", KeyEvent.VK_C);
menu2.add(menuItem);
menuItem.addActionListener(this);
menuItem = new JMenuItem("My Schedule", KeyEvent.VK_M);
menu2.add(menuItem);
menuItem.addActionListener(this);
menuItem = new JMenuItem("Add Leave", KeyEvent.VK_A);
menu2.add(menuItem);
menuItem.addActionListener(this);
menuItem = new JMenuItem("Delete Entry", KeyEvent.VK_D);
menu2.add(menuItem);
menuItem = new JMenuItem("Delete Entry", KeyEvent.VK_D);
menu2.add(menuItem);
menuItem.setEnabled(false);
menuItem.addActionListener(this);
menuItem = new JMenuItem("Edit Entry", KeyEvent.VK_E);
menu2.add(menuItem);
menuItem.addActionListener(this);
// Build the third menu
menu3 = new JMenu("Administrator");
menu3.setMnemonic(KeyEvent.VK_A);
AppletMenuBar.add(menu3);
menuItem = new JMenuItem("Create User", KeyEvent.VK_C);
menu3.add(menuItem);
menuItem.addActionListener(this);
menuItem = new JMenuItem("Reset Password", KeyEvent.VK_R);
menu3.add(menuItem);
menuItem.addActionListener(this);
// Build fourth menu
menu4 = new JMenu("Help");
menu4.setMnemonic(KeyEvent.VK_A);
AppletMenuBar.add(menu4);
menuItem = new JMenuItem("About Holiday Planner", KeyEvent.VK_H);
menu4.add(menuItem);
menuItem.addActionListener(this);
// Add the menuBar to the JPanel
this.add(AppletMenuBar, BorderLayout.NORTH);
thanx in advance guys
Anand

My tip:
Use the method setActionCommand ( "<ActionString>" ) inherited by JMenuItem
from AbstractButton.
In ActionListener-Method actionPerformed(..) you ask the ActionEvent
  if ( <ActionString>.equals ( event.getActionCommand ( ) ) ) {
    // do something
  }Another tip: encapsulate in a method!
  public void addNewMenuItem ( JMenu pMenu, String pName, ActionListener pListener ) {
    JMenuItem menuItem = new JMenuItem ( );
    // ActionCommand-String is set to text of the menu + name
    menuItem.setActionCommand( pMenu.getText() + pName);
    menuItem.addActionListener(pListener);
    pMenu.add(menuItem);
  }The names for several Items should be hold in Constants, used in ActionListener
an in usage of method addMenuItem(..).
Hope this helps
...mART!n

Similar Messages

  • In iCal how do i set an event every 3 months

    In iCal how do i set an event every 3 months.

    Sk8trdad,
    I presume that your question relates to the Calendar App on the iPad.
    You have to use the "repeat>Custom" setting on the Desktop version of iCal.

  • How can I set an event to repeat on a week day rather than a numerical day of each month?

    How can I set an event to repeat on a week day rather than a numerical day of each month? I see an option at the bottom of the repeat window .... but I cannot use it. Actually, when I try it freezes up my Calendar.
    Lorrene Baum Davis

    These scrrenshots are from Snow Leopard - I would think that Lion wouldn't be too much different.

  • How do i set the event duration default

    how do i set the event duration default on my iphone calendar.  it is preset to 1 hour and i want to change the dafault duration time

    Every Printer driver allow you to save a set of settings.
    For instance,
    I defined
    A4 black & white
    A4 colors
    listings black & white (which prints two pages on an A4 sheet)
    listing colors (which prints two pages on an A4 sheet)
    Do the same with your settings.
    Use the item Enregistrer or the item Enregistrer sous to save your settings.
    Yvan KOENIG (VALLAURIS, France) jeudi 15 septembre 2011 18:40:26
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community

  • How do you set repeat events for a given day of the week

    How do you set a repeat event in calender for a given day of the month.  Expample 3rd Wednesday each month?

    Have you read the app store guidelines yet?
    App Store Review Guidelines:
    http://developer.apple.com/appstore/resources/approval/guidelines.html
    Don't go on what you've seen in the store - for every example you spot, there are hundreds that didn't make it in.
    As well, Apple is tightening up on reviews, etc.
    Loads of discussion on this in the iOS Dev Forums, BTW

  • How do I set an event to repeat every 4 weeks on iCal on my ipad 2?

    How do I schedule an event to repeat every 4 weeks in iCal on my iPad 2?

    Wow, I'm so used to setting up most repeated events on my mac in BusyCal that I didn't realize how limiting iPad/iCal was. I'll be curious to see if anyone has a trick to accomplish this. Thanks for posting this "issue".

  • How can I set an event that occurs on the same day, not date, every month? Like Thanksgiving is on the third Thursday of November

    On my PowerBook, I was able to set up events to show up on a specific day repeating each month, say the first Thursday.  How can I get that on the iPad 2?

    For your repeating even, I'm assuming this is your Yahoo calendar? that isn't a Firefox issue, I suggest you try to contact yahoo.
    For the other issue, try the following:
    Update to Firefox 15. Then, [[Reset Firefox – easily fix most problems]]

  • How can we set two events in a single button ???

    HI
    I created a button named bold , when i click it first time the textarea texts will became as bold..
    I created another button bold cancel when i click at that button textarea texts will became plain...
    But how can i set that controls in a single button (in button bold) ???
    Would anybody please tell me ...

    I would have one event listener that is aware of a boolean variable that has scope outside of the event listener, isBold for instance?
    When you click on the button, have the event listener toggle the boolean variable and then if true, set the text to bold, if false set the text to plain.

  • TS3714 how can i set an event in the calander to repeat on 2nd thurday of every month

    how can i get an event to show in calander every 2nd thursday every momth

    Try the app "Week Cal".

  • How do I set an event to repeat on the first tuesday of each month?

    I am trying to set ical for a recurring event, but do not see an option.

    These scrrenshots are from Snow Leopard - I would think that Lion wouldn't be too much different.

  • Latest IOS 7.1 Release - How can I set calendar events to the minute. This was enhanced in ios7 and now has gone back to 5 minute blocks. Why???/

    In IOS6 you could only set calendar appointments at 5 minute intervals. This was fixed in IOS7 but has reverted back in the latest release of IOS7.1. Why? IS there any way to override it. It means I have to go back to my old method of putting my actual golf tee time in the description of the appointment.

    Design change with iOS 7.1. Tell Apple you don't like this here:
    http://www.apple.com/feedback/iphone.html

  • How do I set while loop priority in an RT Field Point application?

    I have a vi that I want to run in an FP2010 that contains 2 while loops, one must be Time Critical priority and the other Normal or lower priority.  I will be using RT FIFO to transfer data between the two loops. The Normal loop will be used for communication with a Host PC.
    How can I set the priorities of these 2 loops?
    Can I run 2 separate vi's in the FP with each set to a different priority And transfer data between the two with RT FIFO? How?
    I am using V6.1 and the customer does not want to spend on upgrading.
    Thanks,
    Chris

    Chris,
    You are on the right track using two separate VIs with different priorities and using RT FIFOs to communicate between the two.  Please see the following tutorial and the related links, one link of which is an example with a zip file containing the RT FIFO VIs for LabVIEW 6.1.
    Doug M
    Applications Engineer
    National Instruments
    For those unfamiliar with NBC's The Office, my icon is NOT a picture of me

  • Can I invoke a SubVI in an event? and how do I set the background color of a pipe to #0000ff?

    When I click an image or a glass pipe(which belongs to Industry/Chesmitry category in palette), I want a SubVI to be invoked.
    The purpose is to fetch an OPC-UA data from a web service and to write to it via the service.
    We are building an HMI solution which displays an interactive water plant diagram.
    When users click pipes and motors in the diagram, clicked devices should be turned on and off and change their animations or colors accordingly.
    OPC-UA is for communication with devices.
    I couldn't even set the background color of a pipe to "#0000ff", but setting it to "Red" or "Blue" was possible, and I don't know how to invoke SubVIs in event scripts.
    The documentations in NI.com are confusing and lack depth.
    Even silverlight references are confusing.
    How do I do all of these?

    Hi iCat,
    Can you provide some more information about your current implementation so that we can help to answer your questions. Some questions I have for you are:
    Are you creating this project in the NI LabVIEW Web UI Builder or in LabVIEW?
    How are you publishing your webservice? Is this also in LabVIEW?
    How is your webservice interacting with an OPC-UA server?
    How is the certification set up with OPC-UA so that you can communicate between the server and the client?
    Best Regards,
    Allison M.
    Applications Engineer
    National Instruments
    ni.com/support

  • How do I create an Event Handler for an Execute SQL Task in SSIS if its result set is empty

    So the precedence on my entire package executing is based on my first SELECT of my Table and an updatable column. If that SELECT results in an empty result set, how do I create an Event Handler to handle an empty result set?
    A Newbie to SSIS.
    I appreciate your review and am hopeful for a reply.
    PSULionRP

    Depends upon what you want to do in the eventhandler. this is what you can do
    Store the result set from the Select to a user variable.
    Pass this user variable to a Script task.
    In the Script task do whatever you want to do including failing the package this can be done by failing the script task, which in turns fails the package. something like
    Dts.TaskResult = Dts.Results.Failure
    Abhinav http://bishtabhinav.wordpress.com/

  • Music and Video on Nas in folders but how do i set up itunes on multiple computers to see and use these files and create libraries?

    Music and Video on Nas in folders but how do i set up itunes on multiple computers to see and use these files and create libraries?
    So i have had a itunes set up on my old PC, bought a NAS and copied the folders over to the NAS, i did this incorrectly and so then even when i told the old PC to use that folder it saw all the songs but wasnt able to play the songs as it was looking in the incorrect place.
    So now i want my Mac as well as my PC and others to all use the music, videos etc on the NAS they are in itunes friendly folders (as they were compiled this way by the itunes on the old PC.
    When i tell the mac to use the itunes library.itl file it sees the song list (about 100gb) but cant see any songs, so i have removed this file to another location for now with the hope to set up a new file and then get it to see the songs on the folder from the NAS.
    Can someone tell me how to do this for all the Mac's and PC's on my network as i really want one master library that all use and add too.
    Thanks for your help in advance.

    I have the same question but I am using two pc's

Maybe you are looking for

  • How to get the connected Adapter Object for a particular BDoc Type?

    Hi All, I have a scenario in which CRM system is connected to ERP system. In SMW01 transaction, I can see one BDoc with BUS_TRANS_MSG as the BDoc Type in CRM. Now, how do I get to know if this one BDoc is a SALESDOCUMENT or SALESCONTRACT. Is there an

  • Getting row currency has changed error and JBO-28010

    Hi Not sure if these two errors are connected I am using Jdeveloper 10.1.3.2 and OAS 10.1.3.1 I have 4 -5 application modules connected to 3 different dB. Two days back i change the database connection to another and released to production because ou

  • Need some help re:  OS 9, OS X 10.2 and Leopard on PowerBook

    I have begun experimenting with a Titanium PowerBook G4 I have that I hadn't used in years.  It had Jaguar and OS 9 installed originaly and I recently upgraded to Leopard.  I then decided that I wanted to see what OS 9 was like so today, I partitione

  • SAPGUI Iview and passing logon language as query string in URL

    Dear Portal experts, is it possible to send the sapgui logon language as query string in URL so sso login to EP is language JP and the login to SAPGUI Iview (for windows) can be different langauge eg English. There is a document that talks abt config

  • Print data of an internal table to a printer.

    Hi, Requirement: The data from an excel file is the input for the program. This data is taken into an internal table using GUI_UPLOAD adn manipulated based on certain validations. The data which is validated is finally collected into an internal tabl