Event in Menu

the book says we can add ActionEvent to menu object(though it is not preferred)
but when I do this in my code it does not work. It shows nothing when I click the menu.
import java.awt.*;
                 import java.awt.event.*;
                 class ExamDemo{
                       public ExamDemo() {
                         Frame f=new Frame("Frame");
                         MenuBar m1=new MenuBar();
                         Menu menu1=new Menu("File");
                         menu1.addActionListener(new MyListener());
                         m1.add(menu1);
                         f.setMenuBar(m1);
                         f.setSize(200,300);
                         f.setVisible(true);
                       public static void main(String args[]){
                       new ExamDemo();    
                class MyListener implements ActionListener {
                   public void actionPerformed(ActionEvent ae) {
                      System.out.println("You have clicked me!");
                }

For Menu/JMenu, addActionListener() is available.
But check the following link for Listeners that Swing Components Support
http://java.sun.com/docs/books/tutorial/uiswing/events/eventsandcomponents.html#many
In that MenuListener alone is listed for menu.
Menu selected/deselected/canceled that can be handled by MenuListener
http://java.sun.com/javase/6/docs/api/javax/swing/event/MenuListener.html

Similar Messages

  • Event repeat menu not showing up

    Some events on my calendar have the repeat option and others don't. I need to set birthdays and anniversaries, etc. as recurring, but the menu isn't on the event. Where did it go?

    See my response on your other post: https://discussions.apple.com/thread/3853688?tstart=0

  • I am unable to merge events running iPhoto '11 - 9.4.2 (710.42) and Mountain Lion, 10.8.2. All options on the events down menu are greyed out and I am therefore unable to merge any events. Is there a solution?

    I am unable to merge events as all drop downs in the events selection in the tool bar are greyed out. Is there a solution?

    Thank you.
    I tried to drag one event into another event but was unable to do so. The event that I tried to move into a second one would only move to another position in the event columnn, but it would not merge into another one.

  • Handle runtime menu in subvi event

    I am passing the runtime menu reference to a subvi event structure for processing the top-level runtime menu in the event case. I already have a registered case to handle any change in the top level vi control values. Since, I'm passing a runtime menu reference to the subvi, I initially thought I can handle the runtime menu in the subvi event. When I add an event, runtime menu is not a choice when setting the event up. The event setup does show "shortcut menu" as a selection but this must be for a context menu or the like.
    Thx ahead of time,
    richjoh

    Hi Richjoh,
    what you should do is pass the VI-refnum into the sub-vi, and register there for menu events! A menu reference, does not cover a FP-object so LV has no events for it.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • I am using the "Menu Selection With Events.vi" example alongside other while loops, When I select exit from the new menu it stops the other while loops but not the menu/event while loop

    The event driven menu example works fine and I've integrated it into my application. I have built in simple local vars to link menu selections to existing GUI buttons. The problem is that I cannot get the File-Exit menu option to switch off/terminate the application. The [1] "Stop": Value Change panel of the event structure simply switches off the other while loops but leaves the event while loop running. Add a while loop to the axample using a local var from the event while loop to terminate 2nd while loop to get the effect.
    Help appreciated, Chris

    Attached you will find a modified version of your VI.
    I documented what I did on the block diagram.You were right on you just needed to add a variable with a true wired to it.
    Have fun with it.
    Joe
    Joe.
    "NOTHING IS EVER EASY"
    Attachments:
    Menu_Selection_with_Events_%26_while_loop[1].vi ‏76 KB

  • Call Menu Event from code

    Good Day
    Experts:
    I would like to call a MenuEvent from code in one of my forms.  A Sub in my Main.vb class called MenuEvent handles which form to open:
    MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean)
    I cannot figure out how to call that MenuEvent from in my form code.  So far I have:
    <b>Project.Class.MenuEvent(test, True)</b>
    test is defined as:
    <b>Dim test As SAPbouiCOM.MenuItem
    test = "AddOper"</b>
    When I run the code to try and call this MenuEvent, I get an error "Unable to cast object System.String to type SAPbouiCOM.MenuItem"
    Does anyone have an feedback that might help me call a MenuEvent from my form code?
    Thanks,
    EJD

    Thanks for the Response Ad
    I did not explain well.  The MenuEvent Sub I have here refers to a Menu that I am loading as an AddOn.  From that menu I am loading forms/screens that were written in VB.Net.  Here is the code for a few of the forms/screen calls in my MenuEvent sub:
    Public Shared Sub MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean)
            Try
                Select Case pVal.MenuUID.ToUpper
                    Case "Test_WO"
                        Dim WOForm As New Test_WO
                        BubbleEvent = False
                    Case "Test_AddOper"
                        Dim WOAddOperForm As New Test_AddOper
                        BubbleEvent = False
                 End Select
            Catch ex As Exception
                HandleException("Event Handler - Menu Event Handler", ex, False)
            End Try
        End Sub
    I want to make a call from this MenuEvent while inside a form/sceen.  This way the User does not have to go back to the Menu list and click on it.  So, I need to call <b>Public Shared Sub MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean)</b> from inside a form/screen.  I canot figure out the syntax to make the Case "Test_WO" fire from inside my form.
    Can you help?
    Thanks,
    EJD

  • Events being triggered more than once

    HI All,
    I am using SAP Business One 2007 A SP:01 PL:07
    I have created a form using SAP Business One UI API Version 2007 A 8.0.When i open the form first time all item events and menu events are working properly..
    When i close the form and open it again all the menu and items events get fired twice.Again i close and reopen the form all Item and Menu events are triggered thrice on a single click.
    Any help to solve this problem will be highly appreciated.
    Warm Regards,
    Prerna

    Hello,
    Maybe You using a global variable for the form. Try to swicth to local variable and use sbo_application.form.GetForm(pval.formtypeex, pval.formtypeCount), or check you application really closes the window (window menü, and see the list of opened forms).
    Try to use EventSpy, which is a part of the SDN tools, you can download from /docs/DOC-8857#section6
    Regards,
    J

  • Photoshop CC Extensions menu is not selectable

    Photoshop CC Extensions menu is greyed out. I cannot select event that menu.
    The extensions installed successfully in Extension Manager CC, no errors. I even tried uninstalling and trying just 1... no dice. I've reinstalled Extension Manager CC without success as well.
    A few of those extensions are scripts and those are available through the File > Scripts just fine, but the Extensions are not. I have no issue at home using them, but here on my work computer I cannot access them at all.
    In Photoshop CC, I cannot even click on the Extensions menu, not even the Exchange is available which is built in:
    I uninstalled and reinstalled Photoshop CC and reinstalled the plugins and I still have the same issue. No error messages, it's just not selectable.
    Any ideas?

    I am on a Mac, but am having the same issue, my extensions is greyed out.
    Also when I open Extensions Manager CC, I get the application launched, but I get no interface, so I can't even see the extensions. I know I just installed onOne Perfect Suite, so it should be showing up.

  • Iphoto imported into events out of order

    I did not state the problem very well the first time.  My pictures I just imported, showed up at the bottom with the correct dates when I viewed them as "photos" under Library on the left; but when I choose to view Events; they show up with among other events from 2010 or 2009.  WHY?   This has happened with several imports in the last 2 weeks.  All dates of photos are correct, but Iphoto places them among events created 2 or 3 years ago.

    See my answer ot your duplicate post  --  while viewing events ==> view menu ==> sort events
    LN

  • Best way to handle several events that may occur simultaneosly

    Hi all,
    I have an application vi in which I need to take care of several user generated events like menu bar selections, mouse clicks on controls (both single & double clicks) and many more.Also, all these events can occur simultaneously.Which would be the best method or architecture to handle all these events with ease?..All suggestions are welcome.
    Can I use dynamic event handling for this?..If so,how can I implement it? (I went through several documents & examples for dynamic handling but none of them explained properly in this context).

    mnx wrote:
    [..] several user generated events like menu bar selections, mouse clicks on controls (both single & double clicks) and many more.Also, all these events can occur simultaneously.[...]
    Hm, can you enlighten us how a user will create these events simultaneously?
    Or maybe i am a bad user as i always use either mouse OR keyboard to control an application, most often not both the same time (starting different "events" concurrently).
    Beside of this discussion, Producer/Consumer is a very good starting point to address this kind of requirement, as already stated above.
    Norbert
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Exception during event processing

    I have an application which has an "exception catcher" at the bottom that performs some "exit work" that I need done when the program terminates abnormally.
    In certain places of the program, I automatically have the program quit and exit by dividing by zero to trigger an exception. Up until today, this technique has worked nicely.
    Today, however, I tried to do it in the middle of an AWT Event (a menu selection from a frame), in the following method:
    public void actionPerformed(ActionEvent event)
    Instead of the exception being handled by my routine, the program instead hangs without getting to the "catch" command that I usually use and instead generates the following sequence of error messages:
    Exception occurred during event dispatching:
    java.lang.ArithmeticException: / by zero
    at WTPFrame.actionPerformed(wtp.java:5335)
    at java.awt.AWTEventMulticaster.actionPerformed(Unknown Source)
    at java.awt.MenuItem.processActionEvent(Unknown Source)
    at java.awt.MenuItem.processEvent(Unknown Source)
    at java.awt.MenuComponent.dispatchEventImpl(Unknown Source)
    at java.awt.MenuComponent.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    Is there any thing I can do to allow this exception to pass through to my handler so that the program doesn't hang?
    Thanks,
    Bruce

    When I was describing the business of subclassing an exception, this was independent of your hanging problem.
    The hanging thing is a consequence of the way that threading is done in a GUI application.
    Your app (by the sound of it) has two threads of execution running. The "main" thread is listening to the socket and running the game. The "EventDispatcher" thread is listening to the mouse and keyboard and redrawing the GUI.
    When a GUI event handler is called, this call is done by the event dispatcher thread. If you throw an exception from the handler, the loop in the event dispatcher thread just prints the stack trace and goes on listening for more mouse and keyboard events.
    To get the threads to communicate, you need for one thread to set a flag that the other thread can read. To interrupt the socket read, you need to call interrupt on the main thread from the gui thread. Lastly, to get the app to exit you must call System.exit().
    class Foo {
      volatile boolean weHaveToExit = false;
      Thread mainThread;
      // this method is called when the user clicks the exit button
      void exitMenuHandler() {
        weHaveToExit = true;
        mainThread.interrupt();
      public static void main(String[] av) {
        mainThread = Thread.currentThread();
        // create the menu
        // attach the event handler to it
         while(!weHaveToExit) {
             // process a game move
         System.exit(0);

  • Problem Importing into iPhoto 11 Events after Photostream

    Before Photostream, importing my photos into iPhoto worked fine for me.  By USB cable from my iPhone or camera, I imported and elected to import all of them.  They showed up under "Last Import", but I also had the option (I forget now the procedures I followed) to sort this Last Import into one or more existing or new Events that I could name.
    I don't know if Photostream has caused the problem, but now after I follow the prior procedure and have a "Last Import" (which does show thumbnails of all the photos), I can't find out to create the actual Events into which I want to place these photos.  If I go to Photosteam, this does not help.  If I go to the automatically created, say, "Dec 2011 Photosteam" event folder, I can (painstakingly) create one or more events into which to sort the pictures in that folder--but at this point I lose many of the photos from that folder.  However, they are still in the main Photostream folder and in "Last Import".
    If I go to "Events" in the source column at the left, I do not see the new pictures (they are only in Last Import, in Photostream, and, sometimes, in the most recent monthly folder automatically created for Photostream).  If I go to the Events dropdown menu, the selections (such as Create Event) are grayed out--irrespective of whether I have Selected All or selected any of the photos in the Last Import or Photosteam folder.  Thus, I can't get hold of the new pictures to put them into the events that I want.
    How do I break apart the individual photos like I used to be able to do, so that I end up with photos divided into existing or newly created events?
    Has anyone run into this problem?  Is anyone doing the same tasks without having any problem of this nature?  Anyone have a solution?

    Okay, I think I've answered my own question, based on my looking further at other questions and answers in this forum.  I needed to control-click on one of the photos in my Photos or Last Import folders and select "Show Event" from the contextual menu at the bottom of the pop-up window.  This directed me way up in my library to near the beginning--instead of at the end (latest date) where I expected to find the event.  I then need to go to the View menu, then down to Sort Events, and then click to Sort By Date (I don't know how this had become un-selected.)
    Once I was able to find the photos, I was able to follow my old procedures to continue creating events and sorting photos--all without needing to go into Photostream (since I had uploaded into iPhoto the photos I wanted to sort by USB cable from my camera and my iPhone).

  • GetSource() of event before

    I have a button, when I have a mouse right-click action, show popup menu,
    In event of menu item og popup menu, I want to get button object?
    How Do I solve this problem?

    more source
    jpanel.add(button)
    button.addMouseListener(new MouseAdapter(){
    public void mouseClicked(MouseEvent event ){
    mouseRightClick(event);
    and
    jpanel.addMouseListener(new MouseAdapter(){
    public void mouseClicked(MouseEvent event ){
    mouseRightClick(event);
    java.lang.NullPointerException
         at hp.co.vn.icafe.core.ui.ClientTabPopup$6.actionPerformed(ClientTabPopup.java:141)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)

  • IPhoto-View Event Titles

    In +View Menu+ there's an option called +Event Titles+ which is active only if you select Photo or +Last Import+ in the Source List.
    I have made some smart albums and when you select one of them the +Event Tiles+ menu is always inactive. But in some of them (it seems the first ones I made) you view the photos as if the +Event Titles+ option was on. In others (the most recent) you view them as if the option is off. I have try new Smart Albums and it seems that they always show without Event Titles. If I duplicate a Smart Album where you see Event Titles the result is the same Smart Album but now without Event Titles.
    I'm mising something, can you help me?

    Thanks, know I understand. And now I know a way to have the Even Titles option active in Smart Albums that are not based in Events. Just make an Smart Album based in Events and then edit it and change the matching condition to the one you really want. Although the new criteria is not based in Events the Event title view will remain. But if you now duplicate the smart album, the copy will display with no event titles.

  • Turn Off / Airport / Menu Item

    Hello,
    I try to make an applescript to turn off Airport by menu items
    I've try this (see below) but it doesn't work on Leopard (french version).
    I've already turn off "Enable Access for assistive devices" in Universal Access.
    Thanks in advance for your help,
    Regards,
    Grégoire
    *tell application "System Events"*
    *click menu bar item 1 of menu bar 1 of application process "SystemUIServer"*
    *click menu item "Désactiver AirPort" of menu 1 of menu bar item 1 of menu bar 1 of application process "SystemUIServer"*
    *end tell*

    The menu position isn't set so you can't assume a numerical index, but you can go through the menu items looking for the one you want. There was an earlier topic about scripting the Airport menu, so I just looked up some keys in the French localized strings. The "Enable Access for assistive devices" will need to be turned on, but the following script should do it:
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #FFDDFF;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    tell application "System Events" to tell process "SystemUIServer"
    tell menu bar 1
    set menu_extras to value of attribute "AXDescription" of menu bar items
    repeat with the_menu from 1 to the count of menu_extras
    if item the_menu of menu_extras is "Menu supplémentaire AirPort" then tell menu bar item the_menu
    click
    delay 0.5
    click menu item "Activer AirPort" of front menu
    -- click menu item "Désactiver AirPort" of front menu
    delay 0.5
    end tell
    end repeat
    end tell -- menu bar 1
    end tell
    </pre>

Maybe you are looking for

  • SQL tooks more time at first and even more thru APP

    Hello, SQL SELECT *   FROM (SELECT CASE                   WHEN 'N' = 'Y'                   THEN                      ABCDEF_security.mask_data (                         SUBSTR (LPAD (ly.MEMBER_name_1050, 6, ' '), 6))                   ELSE           

  • Safari 6.0.5 slows to a crawly Need to relaunch periodically

    I've not had this problem before but over the last few months Safari 6.0.5  slows after a few hours of constant usage. I have turned off plug-ins and disabled my extensions to no avail. The program orks fine until it slows to a crawl. Then I have to

  • AP1232AG Link Role Flexibility

    I tried to setup a 802.11a wireless backhaul using several dual radio AP1232AG with IOS 12.3.8JA and LRF feature. The backhaul consists of a root bridge followed by a daisy-chain of two non-root bridges. Usually non-root bridges only associate to roo

  • Can I temporarily change the filename when using mailDoc?

    Here is the situation: I am creating a form that multiple users will open, fill out, and then click a button to email the form using the mailDoc method. The email goes to an automated document management system that will move the attachment to a fold

  • Why does my indesign keep crashing?

    Hi, So.. I have indesign CS5.5 and recently whenever I open it up it takes over a minute to load and when it does load it automatically crashes. I am using it on a Mac Book Pro and have recently downloaded the OS X Maverick update however the problem