How to get a pop-up menu on right click of JTree?

hi
My application consists of a JTree.I am having a 2 root nodes each one have some child nodes.in the first root node what i want is on right click of child node i have to display one option that is enabled and on the second root node what i want is on right click of child node i have to display one option that is disabled..
how to do that
thanks for your reply in advance,

When you are creating your nodes, do node.setUserObject(objectName);
and on right click, do something like this
if (e.isPopupTrigger() == true) {
         selPath = tree.getPathForLocation(e.getX(), e.getY());
      try {
         // If Right Click, Select the Node
         Object[] selectedPath = selPath.getPath();
         DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) selectedPath[selectedPath.length - 1];
         try {
            dataObject = (MyObject) selectedNode.getUserObject(); // Set the Data Object
         } catch (ClassCastException ex) {
                                  ex.printStackTrace();
         // Check for the right click on Framework Node
         if (dataObject.getClass().isInstance(new MyObject()) == true) {
            // Disable the pop-up menu
....

Similar Messages

  • Pop up menu on right clicking an image?

    Hello,
    I am new to LabWindows/CVI. 
    Requirement: "To get a pop-up menu on right clicking on image"
    Right now, I display my images in window numbers (0 - 15). Is it possible to be able to get a pop-up menu on right clicking an image window. If yes, how? If not, could you please suggest other methods to achieve this task? Should I display the image in a separate parent panel for example? How could I do this?
    Any help would be great.
    Cheers

    I would use the code generator for right click event. then fill it up with whatever code you want under right click case. You can access these when you double click your UIR file, then on the top of the page click Code\Preferences\Default... then choose desired events for picture then go to Code\Generate\all callbacks and skip through the ones you don't want to be replaced.

  • How do I change the pop up menu for right click to Tools?

    Hi,
    I generally know my way around Photoshop but for some reason this has me stumped.
    When I right click on the image I'm working in (using my Cintique pen button) I get the Brushes panel as a pop up.
    Very handy, but I hate Brushes- I much prefer Tools (even if most of my Tools are modified Brushes).
    How do I change this pop up so it shows the Tools?
    I've looked in both the PS prefs and the Cintique settings.
    Think I'm just not doing it right.
    Please help if you know how to make this change.
    Thanks,
    Tom B
    I'm in Mac OS 10.5.8 running PS CS3

    Thanks Trevor, been trying various options along those lines.
    @c.pfaffenbichler
    Yes, I'd like to raise the Tool Presets panel by Right Clicking using the Cintique pen.
    In just the same way as I currently do to access the Brushes panel.
    "Then what did you mean by »even if most of my Tools are modified Brushes«?"
    As above- "A Tool may be a Brush (or an Eraser, or a Cloner, etc) though not all Brushes, etc, are Tools."
    Just as one might say "all swans are birds, though not all birds are swans."

  • Pb with pop up menu on right click

    I have this bit of code in my application
    void jTreeDisk_popupMenu(MouseEvent e)
              if(e.isPopupTrigger() == false ||
                        selectedFile == null)
                   return;
              if(!selectedFile.isDirectory())
                   System.out.println("selected not directory " + selectedFile.getName());
                   //For a selected file all the menu items are visible
                   //Check the availability of the menu item
                   fileExplorerPopupMenu.removeAll();
                   fileExplorerPopupMenu.add(jMenuItemOpen);
                   fileExplorerPopupMenu.add(jMenuItemPrint);
                   fileExplorerPopupMenu.add(jMenuItemMail);
                   if(Desktop.isPrintable(selectedFile))
                        jMenuItemPrint.setEnabled(true);
                   else
                        jMenuItemPrint.setEnabled(false);
                   fileExplorerPopupMenu.show((Component)jTreeDisk, e.getX(), e.getY());
              else
                   //For a selected directory, only "Open".
                   //Window items are visible
                   System.out.println("selectedFile directory " + selectedFile.getName());
                   fileExplorerPopupMenu.removeAll();
                   fileExplorerPopupMenu.add(jMenuItemOpen);
                   fileExplorerPopupMenu.show((Component)jTreeDisk, e.getX(), e.getY());
         }When i run my program within the IDE(eclipse) the popmenu appear, but when i deploy my application and run it, the popupmenu doesn't appear. In fact e.isPopupTrigger always return false, i don't know why.
    My system is windows xp.
    Can someone expain me why this happen and how to solve this.
    Thanks a lot.

    Hi David,
    What mouse event in the method jTreeDisk_popupMenu in which isPopupTrigger() is called - mousePressed, mouseReleased ?
    Also note that "Popup menus are triggered differently on different systems"
    Would you like to try calling the method in deferent mouse events to see if, when it returns true?

  • Why do i keep getting a pop up menu for automatic downloads? I turned it off in the preferences, but it keeps popping up, asking me for my password.

    Why do I keep getting a pop up menu asking me for my password in itunes to enable automatic downloads? I turned it off in the itunes preferences several times.  iTunes still gives me a pop up message asking for my password.  Please help.

    Automatic downloads is for when you download something on your iPhone, iPod touch or iPad and automatic downloads will download these on your Mac or pc, eliminating the need for syncing. But I have limited bandwidth at home so I do not want this feature. Mine actually stopped bugging me for now, I cruised around the whole community looking for an answer and different things seems to be working for different people. It just seems to be a bug that will hopefully be fixed in an update. For me, I put in my password, even though I didn't want it, made sure it's not set to allow automatic downloads and tested it and it worked. It hasnt bugged me since, but it may come back over time.

  • How to get a  pop up window from a jsp  form?

    hello,
    i need to get a pop up window when i click a button on a jsp form page. then
    i have to enter some values and get the result on this child window by clicking a button for calculation on the same child window.
    what mechanism should i follow for this ? anybody , help me plz..

    Then u can make a Applet For that or can make a Frame & open it on the client side.
    it's so simple .
    Do it ok
    Bye
    Harsh

  • Hello, i have youtube videos on my iweb site.  but i would like to know if it is possible to get a 'pop-up' affect when you click on a small photo of the video, to open and play the video in a popup?

    hello, i have youtube videos on my iweb site.  but i would like to know if it is possible to get a 'pop-up' affect when you click on a small photo of the video, to open and play the video in a popup?
    we have tried using video light box, but this doesnt seem to work.

    There's an example of one at the buttom of ths page...
    http://www.iwebformusicians.com/Website-Movie-Video/YouTube.html
    Rather than link to the file, the movie is on a separate web page and uses the code shown on this page...
    http://www.iwebformusicians.com/Website-Photos/Image-New-Window.html
    "I may receive some form of compensation, financial or otherwise, from my recommendation or link."

  • Displaying a context menu on right click on rich tree

    Please see the code below. I want to display a context menu on right click on a rich tree.
    <ui:composition xmlns="http://www.w3.org/1999/xhtml"
          xmlns:ui="http://java.sun.com/jsf/facelets"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:a4j="http://richfaces.org/a4j"
          xmlns:rich="http://richfaces.org/rich">
        <style>
            .col1{ width:50%; vertical-align:top;
        </style>
        <h:form>   
            <h:panelGrid columns="1" width="100%" columnClasses="col1">
                 <rich:tree style="width:300px" nodeSelectListener="#{simpleTreeBean.processSelection}"
                    switchType="client"
                    value="#{simpleTreeBean.treeNode}" var="item" id="item">
                    <rich:componentControl event="onClick" for="menu" operation="show">
                    <f:param value="#{item.data}" name="send" />
                </rich:componentControl>
                </rich:tree>
                </h:panelGrid>
            <a4j:outputPanel ajaxRendered="true">
                <rich:panel>
                    <f:facet name="header">Last Menu Action</f:facet>
                    <h:outputText escape="false" value="Right Click :  #{simpleTreeBean.nodeTitle}" id="selectedNode" />
                    <br/>
                </rich:panel>      
            </a4j:outputPanel>
                 <rich:contextMenu event="oncontextmenu" actionListener="#{SimpleTreeBean.processCurrElement}" attached="true" id="menu" submitMode="ajax">
                <rich:menuItem ajaxSingle="true">
                <b> #{simpleTreeBean.nodeTitle}</b> Send To
                    <a4j:actionparam name="det" assignTo="#{ddmenu.current}" value=" #{simpleTreeBean.nodeTitle}"/>
                </rich:menuItem>
            </rich:contextMenu>
        </h:form>
    </ui:composition> With this code, i need left click at first then right click, then it will show the selected node. I want to get the value of the node title on right click. Please help me with it. The SimpleTreeBean code:
    package com.dW;
    import java.awt.event.ActionEvent;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.Properties;
    import javax.faces.FacesException;
    import javax.faces.context.ExternalContext;
    import javax.faces.context.FacesContext;
    import org.richfaces.component.UITree;
    import org.richfaces.event.NodeSelectedEvent;
    import org.richfaces.model.TreeNode;
    import org.richfaces.model.TreeNodeImpl;
    public class SimpleTreeBean
        private TreeNode rootNode = null;
        private String nodeTitle;
        private static final String DATA_PATH = "images/simpleTreeData.properties";
        private void addNodes(String path, TreeNode node, Properties properties) {
            boolean end = false;
            int counter = 1;
            while (!end) {
                String key = path != null ? path + '.' + counter : String.valueOf(counter);
                String value = properties.getProperty(key);
                if (value != null) {
                    TreeNodeImpl nodeImpl = new TreeNodeImpl();
                    nodeImpl.setData(value);
                    node.addChild(new Integer(counter), nodeImpl);
                    addNodes(key, nodeImpl, properties);
                    counter++;
                } else {
                    end = true; } }  }
        private void loadTree() {
            FacesContext facesContext = FacesContext.getCurrentInstance();
            ExternalContext externalContext = facesContext.getExternalContext();
            InputStream dataStream = externalContext.getResourceAsStream(DATA_PATH);
            try {
                Properties properties = new Properties();
                properties.load(dataStream);
                rootNode = new TreeNodeImpl();
                addNodes(null, rootNode, properties);
            } catch (IOException e) {
                throw new FacesException(e.getMessage(), e);
            } finally {
                if (dataStream != null) {
                    try {
                        dataStream.close();
                    } catch (IOException e) {
                        externalContext.log(e.getMessage(), e);
        public TreeNode getTreeNode() {
            if (rootNode == null) {
                loadTree();
            return rootNode;
        public void processSelection(NodeSelectedEvent event) {
            UITree tree = (UITree) event.getComponent();
            nodeTitle = (String) tree.getRowData();
        public void processCurrElement(ActionEvent event) {
            UITree tree = (UITree)event.getSource();
            nodeTitle = (String)tree.getRowData();
            System.out.println(nodeTitle);
        public String getNodeTitle() {
            return nodeTitle;
        public void setNodeTitle(String nodeTitle) {
            this.nodeTitle = nodeTitle;
    }

    Hi,
    Do you have a solution for this? Looking for exactly the same.
    As far as I have it at the moment I have the backing object added to the attributes of the node:
    <a4j:support event="oncontextmenu"
                                         oncomplete="#{rich:component('foldersContextMenu')}.doShow(event, {})"
                                         actionListener="#{customerBean.buildContextMenu}" reRender="foldersContextMenu, selectedNode">
                                <f:setPropertyActionListener value="#{item}" target="#{customerBean.nodeTitle}"/>
                                <f:attribute name="node" value="#{item}"/>
                            </a4j:support>This allows me to get the object in the backing bean:
    public void buildContextMenu(ActionEvent event) {
            UIComponent component = event.getComponent();
            log.info("component: " + component.getId());
            Category node = (Category) component.getAttributes().get("node");
            log.debug("node : " + node);But how I translate that to setting this as the current node is causing me problems.
    Thanks
    Jon

  • JSF Popup Menu on right click

    Hi ,
    I want to popup menu on right click of any component(say tree).I searched on the net and found the tomahawk <t:popup> component.
    This component popup the menu when mouse pointer enter in to the component but I don't want this behavior.
    I want to popup the menu only when I right click on the component.
    This is sample program
    <t:popup id="a"
    styleClass="popup"
    closePopupOnExitingElement="true"
    closePopupOnExitingPopup="true"
    displayAtDistanceX="10"
    displayAtDistanceY="10" >
    <h:outputText id="oa" value="#{country.name}"/>
    <f:facet name="popup">
    <h:panelGroup>
    <h:panelGrid columns="1" >
    <h:outputText value="#{country.cities}"/>
    </h:panelGrid>
    </h:panelGroup>
    </f:facet>
    </t:popup>
    DO you have any component like this ? Or any other way to do like this ?
    Thanks in Advance,
    KK

    I wrote a component a while back that does something similar to what you want. You'd probably need to fix it up and add any features that you need that it doesn't already have. It pops up a menu on a right-click, it allows you to provide a facet to supply the contents of the menu. I doubt I made sure it works in IE or any browser other than Firefox... so there may be JS issues. It has some other component dependencies you might want to remove also. I could get it to the point where you could try it out and fix it up if you want, but I won't have time until next week.
    Ken Paulsen
    https://jsftemplating.dev.java.net

  • Firefox hangs and will not allow me to access other programs running when I resize a pop up window, move a pop up window, accidentally right click flash content.

    Firefox hangs and will not allow me to access other programs running when I resize a pop up window, move a pop up window, accidentally right click flash content.
    == This happened ==
    A few times a week
    == Not sure when it statrted

    Hi.
    When this happens, please press CTRL+SHIFT+ESC and see how much RAM and CPU Firefox is using. If they're sky high, then... Well, that kind of issues are, unfortunately, more common and the we'd like. Thankfully, 99% of the cases are very easy to solve. However, you do need to diagnose what your exact problem is. Do this:
    #run Firefox in safe-mode to disable all extensions and plugins. If this fixes your issues, be them with RAM or CPU usage, then you know it's a problem with plugins or extensions. Proceed to number 2. If safe-mode doesn't fix the issues, then read bellow, after this list;
    #update all extensions and plugins in your Firefox. If this doesn't solve the issues, proceed to the following number;
    #disable all extensions and plugins in your Firefox (not running safe-mode). Being certain that, as in safe-mode, the problems you're having have gone away, enable one plugin at a time. You should be certain that you WANT that plugin to be enabled, so keep your overall number of plugins as low as possible. When you encounter the problems, you know you've found a problematic plugin, so disable it for good. Keep enabling all plugins (except problematic ones) until you've gone through them all.
    #enable one extension at a time. Again, be certain that you WANT that extension to be enabled, so keep your overall number of extensions as low as possible. When you encounter the problems, you know you've found a problematic extension, so disable it for good. Keep enabling all your extensions (except problematic ones) until you've gone through them all;
    #you're done! You've fixed your problems with problematic add-ons.
    Ok, if disabling all extensions and plugins through safe-mode didn't work to bring Firefox's CPU and RAM usage to good levels, then you have different issue. The most likely scenario is that you have a third party software running on your computer that is messing with Firefox. Do as follows:
    #do a virus/malware check on your computer. If this doesn't fix it, proceed;
    #disable all software running in the background that you don't want to have running in the background (in windows, this is done by pressing WINDOWS+R in your keyboard, typing "msconfig" (without the commas) and pressing enter. Now, under the "Startup" tab, you can uncheck the software you don't want, and reboot your system for changes to take effect. If you're unsure of what software you want running, ask someone with more experience). If this doesn't fix you issues with Firefox, proceed;
    #check your firewall/antivirus/security suite for enabled functions/features that you don't want and/or may be conflicting with Firefox. You'll find that these features are most likely tied to Internet Security features, such as link scanners or URL checkers and the like. If you're not sure they are conflicting with Firefox, simply try to disable to see whether or not that's true. As long as you don't browse the web with your antivirus completely off and your firewall completely turned off, there should be no problems. If this doesn't solve the issues, proceed to the following number;
    #check your operating system security options, mainly advanced options that are not configured by default. While it's very unlikely that this may be the cause of the problem (after all, it's the last item on the list), it's remotely possible. If this doesn't do it, I'm out of ideas. Except make sure you've followed my instructions correctly.

  • "Toast it" appearing in menu when right clicking

    The words "Toast it" appears in menu when right clicking an icon but Toast has been uninstalled. How can I remove it please?

    Try this previous discussion:
    https://discussions.apple.com/message/12533120#12533120
    Re: "Toast It" wont go from contextual menu

  • When i connect i5 to itunes .. i dont get "delete" option for songs upon right click .. can anyone help me with this plz?

    when i connect i5 to itunes .. i dont get "delete" option for songs upon right click .. can anyone help me with this plz?

    Yes, annoying. A couple of options:
    While it's playing the current A song, click on the H song to select it (but not double click to play it), when iTunes jumps to the second A song, press the down key and iTunes will remember that you had that H song selected and will move the selection to the second H song while the second A song is still playing. So, still jumps around, but easy to get back to where you were.
    Create a new playlist for your music, right click on it, select "New Window" and you can browse your music in a second list while the first window continues to play music. But if you then start playing music in that second window, you have to go back to the first window if you want to start browsing again. Not great if you're navigating around to play the next song.
    Play music from iTunes DJ, then as you're browsing around your library, you can add things to play next in DJ, and go back. You can combine this with previous suggestion, to keep DJ open in one window while you browser in the other window.
    None of these are great, but maybe one of these works better than your current workflow.

  • I keep getting this error message when I (right-click) on a photo file on my desktop to burn to a CD. I don't understand this code...does anyone?  Thanks  Ariel**:The disc can't be burned because an unexpected error occurred (error code 0x80020000).

    I keep getting this error message when I (right-click) on a photo file on my desktop to burn to a CD. I don't understand this code...does anyone?  Thanks  Ariel**:    The disc can’t be burned because an unexpected error occurred (error code 0x80020000).

    I tried every obvious solution to this problem with different types of disc (-R; +R; -RW and +RW) and the problem persisted.  Then I read about removing a hyphen in picture filenames.  I renamed all the images and bingo there were no further problems.  Apple should have solved this by now.  This error code has been reported for several years and my MacBook Pro is quite new.  Anyway, I hope this helps.  It does work.
    Piggywiggle

  • Menu on right-click for numeric control

    Hello,
    is there a way to program a "menu on right-click" for a control (e.g. numeric), like there is for table controls?
    I'm working with CVI 8.0.1 
    Thanks & Best Regards,
    Greg

    Yes, every control can be added a popup menu with a few instructions.
    Design the menu nar in the UIR editor; do not associate it to any panel
    Load the menu bar when needed with the line menuHandle = LoadMenuBar (0, "myfile.uir", menuBar): by passing 0 as the panel handle it will not be associated to any of them
    In the numeric callback add these instructions:
         switch (event) {
            case EVENT_RIGHT_CLICK:
                // Context menu
               choice = RunPopupMenu (menuHandle, menuBar_Menu, panel, eventData1, eventData2, 0, 0, 0, 0);
                switch (choice) {
                     case menuBar_menu_item1:
                              // menu item handling code
                              break;
                break;
    Passing eventData parameters to RunPopupMenu function ensures that the menu is displayed at the mouse position.
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • When I click on the gold bookmark icon, the pop up menu does not appear that will let me put tags, folder info etc. How can i get the pop up menu to appear?

    After I click on bookmark icon & it turns gold, the pop up menu that lets me add tags, folders, etc doesn't come up.

    What happens when you click the star (now colored gold) a second time? See the steps in the process of adding a bookmark by the method you are using. Step 1, step 2....
    See: http://support.mozilla.com/en-US/kb/Bookmarks#Making_new_bookmarks

Maybe you are looking for

  • Can't get a blank entry in Choice List of Values (LOV)

    Using Jdev 11.1.1.3 but will be upgrading to 11.1.1.5 in few weeks. Need to display a Choice List that is bound a view object with static data. The List should show a blank item since users don’t need to select any. I am able to display the LOV in th

  • WRT54G. Computer sees network but can't connect over wireless

    So I have a WRT54G router since a couple of years now.  Laptop (Win7 64bit), ipod, ipad, phones can connect to it without a problem, but new computer (Win7 64bit) can't.  I can connect the PC via ethernet without a problem though. I powercycled my de

  • IMac g3 dv not downloading os x 10.3 panther disk

    Hi everyone, My iMac stopped working previously and I was told I had to purchase a new hard drive and install it. I did so, and started my Mac up again. I went into the installation and it got to the 'select a destionation' part. It showed the hard d

  • How do I delete Facebook contacts

    I'm trying to get rid of Facebook birthdays and contacts on both my iPhone 4S and ipad. Settings- FB- Allow these Apps to use your account is turned off and updated but nothing changes

  • Getting an error message trying to update Adobe Flash Player

    Every time I try to update Flash Player for Firefox, by downloading the update from here: http://get.adobe.com/flashplayer/ I get the following error: Host "Unable to load application configuration" Any help would be greatly appreciated!