How to activate a menuitem on popup menu?

hello there
i've made a popup menu with to menu items
PopupMenu popup = new PopupMenu();         
             MenuItem defaultItem2 = new MenuItem("Restore");
              MenuItem defaultItem = new MenuItem("Exit");
              popup.add(defaultItem2);
             popup.add(defaultItem);  and i've put the popup menu on a tray
                           class TrayActionListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
           trayIcon.getPopupMenu();
    };and i want if the user selects the Exit menuitem the program is closed
and if he chooses restore the frame is restored from the system tray
how to do these two action?

thanks dwg but i have a little problem here
i have 2 classes one for the systemtray and other for actions on it
each class is independent
      public void setupSystemTray() {
        if (SystemTray.isSupported()) {
            SystemTray tray = SystemTray.getSystemTray();
            Image image = Toolkit.getDefaultToolkit().getImage("D:\\Other\\JAVA\\Icons\\shutdown.png");
             PopupMenu popup = new PopupMenu();         
             MenuItem defaultItem2 = new MenuItem("Restore");
              MenuItem defaultItem = new MenuItem("Exit");
               defaultItem.addActionListener(this);
              popup.add(defaultItem2);
             popup.add(defaultItem);   
            trayIcon = new TrayIcon(image, "JShutdown Timer",popup);
            trayIcon.setImageAutoSize(true);
            trayIcon.addActionListener(new TrayActionListener());
            try {
                tray.add(trayIcon);
            } catch (AWTException e) {
                System.err.println("TrayIcon could not be added.");
                                       class TrayActionListener implements ActionListener {
        public void actionPerformed(ActionEvent e) {
           trayIcon.getPopupMenu();
         if(e.getSource()==defaultItem)
              System.exit(0);
    };and i want if the user chooses the exit menuitem the program exits
so i write
if(e.getSource()==defaultItem)
              System.exit(0);
         }in the second class the IDE didn't recognize the variable defaultItem
and it gave me error couldn't find simple variable
how to fix that?

Similar Messages

  • How to disable the run-time popup menu in the sequence display on TestStand Operator Interface, that allow the use to skip the test?

    How to disable the run-time popup menu in the sequence display on TestStand Operator Interface, that allow the use to skip the test?

    Hello,
                  Regarding the skip/force pass/force fail options, when I set the ControlExecFlow to True in Teststand 3.1 and 3.5, in the Sequence Editor the menu options for skip/force pass/force fail are not active for Technician but, when I launch the Operator Interface logged with Technician the options are active. The problem is that if the technician sets one step to one of these options, and change the user to Operator, the test step remains skip/force pass.
                  Is there any possibility without modifying the Operator Interface (at programming level), to reload default values of the steps when changing the user to Operator?
    Thank you,
    Best regards,
    paio

  • How do I disable the brushes popup menu when I left click in Photoshop CS5?

    How do I disable the brushes popup menu when I left click in Photoshop CS5? I am trying to use the clone stamp and I am not able to get a sample because of this popup menu.

    LOL,  I can't even begin to complain with the number if times I misread questions, and then try to break my own record for the number of typos in a single post.
    The image above was taken on a photgraphic weekend where the group (of all young ladies ) I was travelling with, set us a photography challenge.  The one above was my response to a 'faceless portrait'.  The only other one I attempted was this response for a picture of a 'wild animal', featuring camera club president Liz.
    Oh what fun we had, laughing and laughing until our faces fell off.
    [EDIT]  Both taken at Karamea, which some visitors to NZ might recognise as the western end of the Heaphy Track.

  • In iCloud Numbers how do I set up a popup menu in an entire column

    I have a database using iCloud Numbers. The table is for my tax deductions for 2014. In one column I have Doctors/Dentists/etc. Instead of typing that title each time I create a new entry in that column, how can I set a popup menu like I can in Excel and choose Doctors/Dentists/etc?

    Hi Aunest,
    You have couple of options here.
    You can make a copy of the site-wide template for every catalogue and build the menu manually.
    The other option is to use:
    {module_cataloguelistdump,-1,rowLength,targetFrame,sortBy}
    Displays the List of all Catalogues as names that are links to those catalogues
    Parameters:
    Use -1 to display parent catalogs, use -2 to display all catalogs including sub-catalogs or a catalogue ID to display the subcatalogues of a particular catalogue
    rowLength - will limit the number of items per row when items are displayed as a list. Default is 1 item per row.
    targetFrame - e.g. _blank. Specify the frame you want the item to open in
    sortBy - will sort the web apps in specified order
    Alphabetical - sorts items alphabetically
    Weight - sorts items by weight
    Example
    {module_cataloguelistdump,-1,1,_blank,Alphabetical} - this module will display the catalogue list in the new window, alphabetically and all in one column
    Cheers,
    -mario

  • How to open 'share picture via' popup menu on android?

    Hi there.
    I made a little photo painting app on android where you can open (via the native file opener with filerefence.browse() it works beautifully) and save (directly to CameraRoll with addBitmapData also works perfectly) an image. Now i would like to share the saved image.
    I would like to use the native android 'share picture via' popup. I found on a forum the native code for it ( http://stackoverflow.com/questions/3553017/android-share-via-dialog ).
    Since we cannot execute native code for mobiles as i can read from the flash doc, is there a way to get this working at all?
    Thanks a lot for the help!

    I too would like to know if this is possible. I use it all the time with native apps to send files to my dropbox. If it was up to me, this would be a MUST HAVE feature.
    Mike

  • How to create ADF tree and popup menu by ADF

    Hi All,
    I want to create a tree, and display different context menu when click right click on different tree node.
    please give me a example or Some step to step tutorial .
    Thank you

    Here are a couple of Tree tutorials:
    http://www.oracle.com/technology/oramag/oracle/09-jul/o49frame.html
    http://download.oracle.com/docs/cd/E12839_01/web.1111/b31974/web_masterdetail.htm#BJEBEEJD
    http://one-size-doesnt-fit-all.blogspot.com/2009/09/jdev-11gr1-aftree-mashup-using.html
    http://www.connotea.org/user/jdeveloper/tag/tree
    Edited by: Shay Shmeltzer on Sep 27, 2009 10:51 AM

  • Adobe Reader 7 - Hide document pane popup menu

    Hello,
    in Adobe Acrobat Reader 7 I would like to avoid users accessing the Preferences panel. I have hidden the corresponding toolbar and menu items via javascript. But I don't know how to hide the document pane popup menu (a triangle in the upper right corner of the document pane), which offers another way to access the preferences dialog.
    Can this be done via javascript as well or is there any other chance to do that?
    Thanks for your help.
    St.M

    Hello,
    thanks for the reply.
    So, is this feature (document pane popup menu) a Adobe Reader 7 specific one, because I've never seen this triangle in Reader 8?
    Thanks
    St.M

  • How to inform user that there is an attached popup menu....

    Hi ,
    I have some popup menus on some text items......
    Until now , i have inserted a hint which is displayed automatically when the user activates these text items ..... but the hint is dispayed at the bottom... and the user may not see it....
    How can i make it more 'visible'....?????
    I use Dev10g
    Many thanks,
    Simon

    Use the WHEN-NEW-ITEM-INSTANCE and if the item has a
    popup menu change the colorBut then you'll have to change it back again when the user leaves the field, which I don't believe is possible when you have list items (especially in multi-record blocks) because of when the when-new-item-instance trigger fires for these items. Even at the pjc level poplists behave strangely with regards to their focusGained (or whatever it's called) event.

  • Popup menu on menuItem

    I want to show the popupmenu when users do the right click on the menuitem to do something like the mozilla or internet explorer Favorites menu which can be do right click to show the popup.
    I tried this, but i always have the following problems:
    1) I open the popupMenu with the popup.show( jmenuitem, mouseEvent.getX(), mouseEvent.getY())
    I got the error : java.awt.IllegalComponentStateException: component must be showing on the screen to determine its location
    private JMenuItem getAddMenuItem() {
              if (addMenuItem == null) {
                   addMenuItem = new JMenuItem();
                   addMenuItem.setText(" Favourites    ");
                   addMenuItem.addMouseListener(new MouseAdapter() {
                        public void mousePressed(java.awt.event.MouseEvent e){
                             System.out.println("Mouse Pressed: "+e);
                             if(SwingUtilities.isRightMouseButton(e)){
                                   System.out.println("Right mouse action");
                             if(SwingUtilities.isLeftMouseButton(e)){
                                  System.out.println("Left Mouse action");
                                                   //Here i will open a dialog for the user
                                     public void mouseReleased(java.awt.event.MouseEvent e) {
                             System.out.println("Mouse Released: "+e);
                             if(SwingUtilities.isRightMouseButton(e)){
                                   System.out.println("Right mouse action");
                                   addMenuItem.add(getPopUpMenu());
                                   if (popUpMenu.isPopupTrigger(e)){
                                        System.out.println("Triggered2");
                                        popUpMenu.show(e.getComponent(), e.getX(), e.getY());
                             if(SwingUtilities.isLeftMouseButton(e)){
                                  System.out.println("Left Mouse action");
                   });     so how can i make the menuItem available on the screen to add the popup menu to it?

    I didn't see your code but a meunitem on a menu can be another menu. I think that shoud be enough for your requirement.

  • How to get system popup menu in java?

    I want to know how to get windows xp or any operating systems default popupmenu in java.
    And i also have problem for using mnemonic for JPopupMenu, it works well when i first press right click of my mouse and use the specified mnemonic for that the action specifed for that is triggered but when is use mnemonic without the using my mouse it doesn't trigger why.

    Please how to get native(e.g windows explorer) popup menu in jfilechooser

  • How to create a splitted button with a popup menu?

    Hi,
    i am trying to build a button which can be clicked and an action is called (a normal button) and an addion to that basic function: there is on the right side of the button a seperated area with an arrow. If this arrow is clicked a popup menu becomes visible and you can choose a special action. This type of buttons (i don't know the name) can be seen by example in Eclipse or the Windows Media Player 11 or in Windows Vista).
    Here is an example image about what i mean: http://s2.imgimg.de/uploads/button56b4941cpng.png
    Can you tell me how to create a button with this possabilities?
    Please help me,
    greetings from germany,
    picard90

    hii,
    if you are want completed to define the Popup, then you have to define accesible areas,
    1/ create Popup (example from void)
    public void createPopupMenu() {
    JPopupMenu popup = new JPopupMenu();
    popup.addSeparator();
    ShowsManFxMenuItem = new JMenuItem("Show Details");
    ShowsManFxMenuItem.addActionListener((new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    //..some actions
    validate();
    repaint();
    popup.add(ShowsManFxMenuItem);
    MouseListener popupListener = new PopupListener(popup);
    //here is your listener directly to prepared object "yourButton"
    yourButton.addMouseListener(popupListener);
    2/ create POpupListener (example is class)
    class PopupListener extends MouseAdapter {
    JPopupMenu popup;
    PopupListener(JPopupMenu popupMenu) {
    popup = popupMenu;
    @Override
    public void mousePressed(MouseEvent e) {
    maybeShowPopup(e);
    @Override
    public void mouseReleased(MouseEvent e) {
    maybeShowPopup(e);
    //only in this block you can restrict anything with popup items (test anything and then to display all, only one, parts of them)
    private void maybeShowPopup(MouseEvent e) {
    if (e.isPopupTrigger()) {
    popup.show(e.getComponent(), e.getX(), e.getY());
    //these parts you can ingnore, but can covered extended events from popup
    public void actionPerformed(ActionEvent e) {
    JMenuItem source = (JMenuItem) (e.getSource());
    public void itemStateChanged(ItemEvent e) {
    JMenuItem source = (JMenuItem) (e.getSource());
    protected String getClassName(Object o) {// Returns just the class name -- no package info.
    String classString = o.getClass().getName();
    int dotIndex = classString.lastIndexOf(".");
    return classString.substring(dotIndex + 1);
    3/ I removed all my addition
    ... kopik

  • How to convert text values in a popup menu to numerical values?

    Hi there,
    I am trying to create a table in Numbers where one cell needs to have a numerical value inserted into it based upon the value chosen in a popup menu in another cell, and I'm not sure how to go about it.
    To be more specific, I have a cell containing a popup menu with the items "Bronze", "Silver", "Gold" and "Platinum". Depending on which value is chosen, I need another cell to be populated with a value of 1,1.5,2 or 2.5 respectively, as I will then use this value to perform a multiplication elsewhere in the table. I have tried using the IF function in the 2nd cell but I can only get that to match one value and not an array of values.
    Could anybody advise on the most effective way of accomplishing what I am trying to do?
    Many thanks in advance.

    Michael Quayle wrote:
    (1) Hopefully you're not looking for points for being helpful, because all you're doing here is patronising me from the looks of it.
    "The fact to be a newbie doesn't prevent someone to have a quick look, at least to the list of available functions, to know what may be done with the tool."
    (2) This was *obviously* the first thing I did, followed by a Google search. When those avenues were exhausted I tried here. However, like I said, having "a quick look" is useless if you are not familiar enough with spreadsheets to know what it is you are looking for! MY choice of language to describe what I was trying to achieve was obviously not compatible with any search I performed, which is why I had to resort to asking a person rather than a manual. And frankly, the language used within the documentation is often rather alien to me. Having read the documentation for VLOOKUP I still don't fully understand its application. I'm a musician for heaven's sakes - everybody knows we can't read!
    "The users guides were designed to help users, not to help helpers to help users "
    (3) Are all your posts this condescending? I came here to ask a question, not to be accused of being lazy and not reading documentation. Like I said, my own searches through the manual were fruitless, so I came here for help. Are all the responses on this forum so cold and terse?
    (1) Don't worry, I'm not here to grab points.
    (2) Searching in the existing threads with the available tool seems more logical than searching in Google.
    (3) I write what I want, the way I want.
    In the cell C2 of the main table, the formula is :
    =IF(ISBLANK(B2),"",VLOOKUP(B2,vlook_up :: A:B,2,FALSE))
    Apply fill down to fill other cells.
    Yvan KOENIG (VALLAURIS, France) jeudi 4 août 2011 12:55:03
    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
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • How to create a 3 or more level Popup menu

    Hello,
    I know how to create a 2-level menu for somehting like:
    Fruits>Apple
              Banana
              Oranges
    var choice = app.popUpMenuEx(
         {cName: "Fruits",
          oSubMenu: [ {cName: "Apple", cReturn: "Apple" }, {cName: "Banana", cReturn: "Banana" }, {cName: "Melon", cReturn: "Melon" } ]},
    But what would the code look like for something like (3 level):
    Fruits>Apple
              Banana
              Oranges>Navel
                            Valencia
                            Moro (Blood)
    or even something like this (4-levels):
    Location A......>Site A......>Properties...>Property1
                                                                Property2
                                                                Property3
                            Site B>
                            Site C>
    Location B>
    Location C>
    So overall, how would the above script for a 2-level popup menu be modified for a 3, 4, or more level popup menu?

    Hi,
    You can add the oSubMenu values at any level, so;
    var choice = app.popUpMenuEx(
         {cName: "Fruits",
          oSubMenu: [ {cName: "Apple", cReturn: "Apple" },
                      {cName: "Banana", cReturn: "Banana" },
                      {cName: "Oranges",
                       oSubMenu: [ {cName: "Navel" },
                                   {cName: "Valencia" },
                                   {cName: "Moro (Blood)" } ] }
    console.println(choice.toSource());
    Would give you the menu in your first example.  If the cReturn value is the same as the cName then you can just leave it off (as I have for th 3rd level menu).
    Regards
    Bruce

  • How do I re-order popup-menu (open in new tab to the top)

    Popup-menu is reordered to have share-option at the top in the new version of android browser.
    How do I change the open in new tab-option to be the topmost option?

    Hi mtolvane,
    Currently in the customize options of Firefox for Android, this is not a feature. I would recommend requesting the feature in a bug.
    [https://bugzilla.mozilla.org/show_bug.cgi?id=1025326] I filed this bug.

  • How to change the selection background color of the selected item in the popup menu of the choice box ?

    How to change the selection background color of the selected item in the popup menu of the choice box ?
    By defaut, the selection background color likes "blue", but if I want it to be "yellow" for example, how should I do ?
    Thanks

    The id is applied by (I think) the skin class of the ChoiceBox. You don't need to define it.
    You have to apply the css in an external style sheet. You can apply the external style sheet to any parent of your choice box, or to the scene (the most usual way to do it).
    Example:
    import java.util.ArrayList;
    import java.util.List;
    import javafx.application.Application;
    import javafx.scene.Scene;
    import javafx.scene.control.ChoiceBox;
    import javafx.scene.layout.VBox;
    import javafx.stage.Stage;
    public class ChoiceBoxTest extends Application {
      @Override
      public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("Example 2");
        final ChoiceBox<String> choiceBox = new ChoiceBox<>();
        List<String> tempResult = new ArrayList<String>();
        for (int i = 0; i < 10; i++) {
          tempResult.add("Item " + i);
        choiceBox.getItems().setAll(tempResult);
        VBox root = new VBox();
        root.getChildren().add(choiceBox);
        final Scene scene = new Scene(root, 300, 250);
        scene.getStylesheets().add("choiceBox.css");
        primaryStage.setScene(scene);
        primaryStage.show();   
      public static void main(String[] args) {
        launch(args);
    choiceBox.css:
    @CHARSET "UTF-8";
    #choice-box-menu-item:focused  {
    -fx-background-color: yellow ;
    #choice-box-menu-item .label {
    -fx-text-fill: black ;
    Message was edited by: James_D

Maybe you are looking for