How to get a node  in a Jtree on which right mouse button is clicked

I am dealing with a situation in which whenever tree component is clicked by right mouse button I am needed to get the tree node on which right mouse button was clicked.

MouseEvent e = ...
TreePath path = tree.getPathForLocation(e.getX(), e.getY());
Object nodeClickedOn = path.getLastPathComponent();Or something along those lines.

Similar Messages

  • How to get each node in tree?

    how to get each node in tree?
    Message was edited by:
    NikisinProblem

    how to get each node in tree?
    Since (as far as I know) treeNode is an interface, the real question to me is how are you implementing your treeNodes? Are you overriding the toString() method?

  • How to get the node id of the content shown from campaign

    Hi
    Can any one please tell how to get the node id of the content shown by the campaign
    in jsp
    Thanks

    One option is to define a custom ad renderer, which is registered with the proper mime-type.
    The campaign would run your renderer if the campaign retrieved a node with a binary of the proper registered mime-type.
    This allows you to insert yourself into the call chain for the node rendering. You can access the nodeID at that point (and do the typical rendering-- providing a URL for the ShowPropertyServlet)
    -Steve

  • How to get the node value of payload

    Hi
    The null is returned when I use the following code to get the User_ID element in the payload, but there are values in the User_ID element of the payload
    Task task_test = wfSvcClient.getTaskQueryService().getTaskDetailsById(wfCtx, taskId);
    System.out.println("the payload value is " + task_test.getPayloadAsElement().getElementsByTagName("User_ID").item(0).getNodeValue());
    How to get the node value of payload ? any suggestion?
    Thanks
    Jayson

    Hi Jayson,
    Try:
    System.out.println("the payload value is " + task_test.getPayloadAsElement().getElementsByTagName("User_ID").item(0).getFirstChild().getNodeValue());
    So add the getFirstChild() call in between.
    If this works, maybe consider using JAXB to marshall the payload details to POJO's. This will make reading the payload details much easier.
    Regards, Ronald

  • How to get the specific name of the workset which is currently selected by the user in sap portal 7.0

    Dear Expert,
    I have one requirement like to read the selected workset name in portal by the current user.I have read two documents regarding how to retrieve the PCD contents (iViews, Pages, Worksets and Roles) and its properties like Created by, Changed by, Last changed by and others using PCD API.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/6112ecb7-0a01-0010-ef90-941c70c9e401?overridelayout=true
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/508baf88-9335-2d10-efa6-c6ad61e5fc4b?quicklink=index&overridelayout=true
    But I am not able to understand how to get the specific name of the workset which is currently selected by the user.Can you please help me.
    I am using portal 7.0.
    Thanks & Regards,
    Patralekha

    Hi Expert,
    I found that we can use Interface INavigationHelperService to read Portal Role selected by user at runtime from http://scn.sap.com/thread/52194
    But this class is available in SAP NetWeaver 7.30 Enterprise Portal .
    But in SAP NetWeaver 7.0 Enterprise Portal that interface is not available.
    INavigationService is available there.
    But didn't get any proper discussion on this interface for the same requirement.
    Can you please help me.
    Thanks & Regards,
    Patralekha

  • I never used this program before. I tapped on the "budget form" and decided I'd rather use the "expense form".  I can't figure out how to get to the page that you choose which form you want

    I never used this program before. I tapped on the "budget form" and decided I'd rather use the "expense form".  I can't figure out how to get to the page that you choose which form you want. How would I do that?

    Pct,
    In the Numbers spreadsheets window where all your documents are shown as icons, tap the Plus Sign.
    Choose Create Spreadsheet
    Select the template you want to use
    Jerry

  • How to get indesign from iMac to mac powerbook which does not have cd slot?

    how to get indesign from iMac to mac powerbook which does not have cd slot?

    That will not work!
    You cannot copy or migrate Adobe applications from computer to computer. There are a whole host of files in different locations which have to be installed, and copying will not do it.
    In fact, you'll now have to use the Adobe Cleaner tool to remove the mess you created. You can get to it here:
    Use the CC Cleaner Tool to solve installation ... - Adobe

  • How to get correct node in JTree with DISCONTIGUOUS_TREE_SELECTION mode?

    The following code creats a JTree with DISCONTIGUOUS_TREE_SELECTION mode. When select a single node, the node's name is printed correctly as expected. However, in Window environment, after select one node, if holding the ctrl key and select a different node, the program still prints out the name of the first selected node although both nodes are highlighted. Can some one tell me how to get the name of the second (i.e. the last) selected node printed?
    Thank you very much!
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.event.*;
    import java.io.*;
    public class TestTree extends JFrame {
    JTree tree;
    public TestTree() {
    super();
    setBounds(0,0,500,500);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    tree = new JTree();
    getContentPane().add(tree);
    TreeSelectionModel model = new DefaultTreeSelectionModel();
    model.setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    tree.setSelectionModel(model);
    tree.addTreeSelectionListener(new TreeSelectionListener() {
    public void valueChanged(TreeSelectionEvent e) {
    Object obj = tree.getLastSelectedPathComponent();
    System.out.println(obj.toString());
    public static void main(String [] args) {
    TestTree test = new TestTree();
    test.show();

    Hi!
    Try this, maybe it's what you want?
    /Smedman
    public void valueChanged(TreeSelectionEvent e)
        TreePath[] paths = tree.getSelectionPaths();
        for (int i = 0; i < paths.length; i++)
            System.out.println(paths.getLastPathComponent());

  • How to get a Node with Empty Text in a JTree

    Hi,
    I want to get the node which does not have any text and I want to get it when the tree expands NOT when the user selects a node( thats pretty easy)
    Thankx in advance...

    What do you mean by "get"?Since I would like to remove such a node therefoe I would like ot kow if such a node is in my JTree
    Thankx

  • How to get the Node Value from XmlValue result?

    Hi ,
    I am not able to get the Node Value from the result. In my XQuery im selecting till a Node, if i change my query as
    collection('PhoneBook')/phone_book/contact_person/address/string()", qc);
    im getting the node value, but here the problem is its not a Node so i cannot get the Node name.
    So how can i get the Node Name and Node value together?
    any help please ????
    XML :
    <?xml version="1.0" encoding="UTF-8"?>
    <phone_book>
    <contact_person>
    <name>
    <first_name>Michael</first_name>
    <second_name>Harrison</second_name>
    </name>
    <address city="yyyyy" pincode="600017" state="xxxxx">
    176 Ganesan street, Janakinagar, alwarthirunagar
    </address>
    </contact_person>
    <phone_number type="mobile">9881952233</phone_number>
    <phone_number type="home">044-24861311</phone_number>
    <phone_number type="office">080-12651174</phone_number>
    </phone_book>
    Code:
    XmlQueryContext qc = manager.createQueryContext();
    XmlResults rs = manager.query
    ("collection('PhoneBook')/phone_book/contact_person/address", qc);
    while(rs.hasNext()){
    XmlValue val = rs.next();
    System.out.println(val.getNodeName() + " = [ " + val.getNodeValue() + " ] ");
    Output
    address = [  ]

    You are right, this seemed un-intuitive to me too, but I finally understood how it's done.
    The "value" of a node is actually the total amount of text that is not contained in any of the node's child nodes (if any). So a node with child nodes can still have text value.
    To get the 'value' of an element node, you must therefore concatenate the values of all children of type "XmlValue::TEXT_NODE", of that node. Try it.
    In your example, the <address> node has no child elements, my guess is that BDB XML stores the address string "176 Ganesan street, Janakinagar, alwarthirunagar" inside a child node of <address> node (of type XmlValue::TEXT_NODE) because you wrote the string on a separate line.

  • How to select a node in a JTree by name

    I have a JTree in my program. I want to programmatically set one of these nodes selected by the name of the node. I do not know how to do this. I read the "How to use trees", but no help
    Thanks!

    I have a JTree and each node on the JTree has a string name. I also have a JEditorPane that lists all these names at start up. If the user clicks on one of these names, I want to catch the HyperlinkEvent and automatically select that node in the JTree.
    So in short, I have the String name of the node that I want to programatically select.
    Thanks!

  • How to get a TreeNode from a JTree

    Hi,
    I'm trying to get a TreeNode from my JTree.
    I have problems getting it.
    I can get the selected object but it is not a TreeNode .
    I need it because I need the node's children.
    What I mean is - if I do the next :
    TreePath treePath = tree.getSelectionPath();
    Object o = treePath.getLastPathComponent();
    if( o instanceof TreeNode ) {
    System.out.println("YES");
    else
    System.out.println("NO");
    I get the "NO".
    Thank's,
    Bnaya.

    hi,
    Can u pls jus cast into TreeNode!!!
    Object o = (TreeNode)Treepath.getlastPathComponent();
    if()
    thank u ...
    Shalinipriya.
    }

  • HOw to get parent node name value through its child node?

    Hi,
    Experts,
    I am able to get child node name values but according to attribute name value i want to  get its parent name value how to achieve that. For that i have used If_Ixml_element->Get_parent. Please pass some idea on it.
    Thanks in advance,
    Shabeer ahmed.

    Hello Shabeer
    I think the coding should be straightforward:
    DATA: lo_element   TYPE REF TO if_ixml_element,
              lo_child        TYPE REF TO if_ixml_node,
              lo_parent      TYPE REF TO if_ixml_node.
    " NOTE: LO_ELEMENT holds your child node
      lo_child ?= lo_element.
      lo_parent = lo_child->get_parent( ).
    Regards
      Uwe

  • How to highlight a node in a JTree???

    I am trying to highlight (actually set the Font to Bold) one node of a JTree when an TreeSelectionEvent occurs (valueChanged method). The node to be highlighted can be different than the one selected.
    Thanks for your help.
    JavaSan

    To control the appearance of tree nodes, you need to write a TreeCellRenderer. Check Sun's tutorial on how to use trees (there's a link to it in the API documentation for JTree). The signature of the method you need to implement is this:
    public Component getTreeCellRendererComponent(
        JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)so as you can see, you can vary the appearance of the node based on any of the parameters of that method.

  • How to use custom nodes in a JTree without reinventing the wheel?

    Hello,
    Each node contains two JTextAreas in a Box layout and a few JButtons.
    I wish to display these nodes in a JTree.
    Reading the tutorial, it seems I would have to reimplement the TreeModel, TreeCellRenderer/Editor, MutableTreeNode interfaces etc.
    Can I use the DefaultTreeModel, and other standard widgets (great stuff!) to minimize the amount of reimplementation I must do. aka avoid reinventing the wheel? I was thinking of extending my node from the DefaultMutableTreeNode class - however it does not display the nodes with the TextAreas, buttons etc.
    any help appreciated.
    thanks,
    Anil

    was able to fix it over here:
    http://forum.java.sun.com/thread.jspa?messageID=4089777

Maybe you are looking for