Getting node location in a JTree

Hi all,
I am writing an application that is using a JTree. I need to allow reordering of the nodes as well as droping a node on another node(leaf as well as non-leaf) using drag and drop.
In my code, I cannot distinguish between dropping on a node and dropping between two nodes. My code treats both of these situations the same. How can I distinuish between these two?
I have tried to even look at getRowForLocation(), but it would treat both of these the same as well.
Any comments/suggestion would be appreciated.
Thanks,
PF.

What exactly do you mean by dropping BETWEEN two nodes?
I think the dragged node will drop into the node on which last selection occurred while dragging. Isn't that the case u r facing?

Similar Messages

  • Get node jtree without click

    hi all,
    I want get node from jtree without click, just with mouse in node.
    I look in google but dont find nothing...
    I try use listener but MousePressed dont help-me.
    thanks

    jTree1 = new JTree1(treeModel);Sorry, now
    jTree1 = new JTree(treeModel);
    MouseMotionListener mm = new MouseMotionListener(){
          public void mouseMoved(MouseEvent e) {
                System.out.println("moved "+e.getX()+" "+e.getY());
                 int selRow = jTree1.getRowForLocation(e.getX(), e.getY());
                TreePath selPath = jTree1.getPathForLocation(e.getX(), e.getY());
                if(selRow != -1) {
                                    System.out.println("mouse moved..."+selPath);
        public void mouseDragged(MouseEvent e) {
                   System.out.println("dragged "+e.getX()+" "+e.getY());
    jTree1.addMouseMotionListener(mm);
    jScrollPane1.setViewportView(jTree1);

  • 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.
    }

  • Error pushing client "Failed to get DP locations as the expected version from MP...."

    I am new at SCCM.  installed 2012 R2 and SQL 2012 R2 on a single server.   I created a boundary and a boundary group and ran discover on my AD.  I am trying to push the client to a couple of discovered PCs.  I resolved an issue with a
    permissions error accessing the \admin$ share, but now I'm getting "Failed to get DP locations as the expected version from MP servername..."
    I'm seeing this in the client ccmsetup.log
    I've tried everything I can think of and still can't fix it.   I have checked my DP and it was set to HTTP.   Can anyone help offer some suggestions?
    Thanks

    The error means the expected version of Client Package cannot be got from DP. Please update Client Package from Package Node in SCCM Console, then observe the distmgr.log to make sure the updated pkg has been distributed to DP, then try again.
    Juke Chou
    TechNet Community Support

  • I'm trying to get a TreeNode from my 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.

    Try this code:
    DefaultMutableTreeNode node =(DefaultMutableTreeNode)myTree().getLastSelectedPathComponent();
    if (node == null) return;
    Object nodeInfo = node.getUserObject();

  • How to get the location of a jarfile in the java 1.6 cache

    In 1.5 i am using getResource() to get the location of the jarfile i need, but in 1.6 this does not work anymore. I found a webpage with a workaround for this, but unfortunately i did not bookmark it and i can't find it again. Does anybody know how to get a file url instead of an http url to the jar file?
    I need the location to this jarfile. There is no other workaround and please DO NOT respond and tell me, that i don't need the location in the cache! I read all threads on the java forums to this issue and i didn't find a good answer.

    java.io.File class can be used.
    File f = new File("filename");
    S.O.P(f.canRead());
    S.O.P(f.canWrite());You can set the attribute using Runtime class.
    Runtime r = Runtime.getRuntime();
    Process p =r.exec("attrib -r file");If you are working with unix,
    r.exec("chmod -permissionoptions file");

  • How can we get the location from location area code?

    Hi All,
    i have an application which successfully runs on Motorola L6 and it gives me the cell-id, Location area code, and Mobile Network Code, and Mobile Country Code. Now I want to know how can I get the location ( I mean the name of the location) through location area code. And one more thing can we get current MNC and current MCC through j2me because I have written a code for getting this information for sony ericsson cells but dont have a handset to try out. Anyway if anyone has the information then please let me know
    Thanks in advance
    Sunil

    I donot think you have a direct blog..
    check this blog for java proxies ..
    /people/prasad.ulagappan2/blog/2005/06/27/asynchronous-inbound-java-proxy
    AND CONFIGURE A RFC..

  • Get current LOCATION in ProcessFlow (PF) or Mapping

    How can I get current LOCATION from running PF or Mapping?
    I need to run PF.
    Name of PF passing via parameter of PF.
    I know about wb_rt_api_exec.run_task, but first parameter is LOCATION.

    It is possible to get location from ALL_RT_AUDIT_EXECUTIONS OWB public view (column OBJECT_LOCATION_NAME),
    if I understand your requirements properly.
    Filter rows from ALL_RT_AUDIT_EXECUTIONS via execution_audit_id, in processflow you can use predefined variable AUDIT_ID for currently running processflow audit id
    Regards,
    Oleg

  • How to get Folder Location by just providing folder name ?

    Hi,
    I want to get folder location by providing its name.
    I created one folder on "E:\" drive and when I used following code in netbeans it giving me the current loaction of java file.
    File directory = new File("SVN");
            boolean isDirectory = directory.isDirectory();
            if (isDirectory) {
                // It returns true if directory is a directory.
                System.out.println("the name you have entered is a directory  : "  +    directory); 
                //It returns the absolutepath of a directory.
                System.out.println("the path is "  + directory.getAbsolutePath());
            else {
                // It returns false if directory is a file.
                System.out.println("the name you have entered is a file  : " +   directory);
                //It returns the absolute path of a file.
                System.out.println("the path is "  +  directory.getAbsolutePath());
        }And i got following output
    the name you have entered is a file  : SVN
    the path is C:\Users\AjayS\Documents\NetBeansProjects\TestCodes\SVNBut my folder is located on "E:\" drive.
    Regards,
    Ajay

    You will have to search for them. But that indicates something seriously wrong with the requirement. In effect you're using the local filename as a secondary key but there is no index on it. You should consider a database.

  • How to get the Location of the Device

    hi all,
    I want to find out the Location of the MObile device.
    I am trying to find out with the help of the Location API which was available in the CLDC 1.1.I am using the following code to get the Location
    try{
         Criteria cr = new Criteria();
         cr.setHorizontalAccuracy(500);
         LocationProvider lp = LocationProvider.getInstance(cr);
         Location l = lp.getLocation(60);
         Coordinates c = l.getQualifiedCoordinates();
         if(c!=null)
         double lat = c.getLatitude();
         double alt = c.getAltitude();
         double lon = c.getLongitude();
         locate = c.convert(alt,1);
    }catch(Exception e){System.out.println(e);}
    I used a seperate thread to get the Location.The thread was running it was not diaplying any value(in the Emulator).Can anybody tell me the possible output when we use the Emulator.
    Please help me,Thanks in advance
    Lakshman

    hi,
    Even though the Nokia was the leaders of the JSR 179.but the Specification were developed by the sun.So to my knowledge the device which will support CLDC 1.1 will support my code.
    at present i had a Blackberry 7100t,I have to check whether the device support the CLDC 1.1
    can anybody please tell me what are the mobile devices that support the CLDC1.1?
    lakshman

  • How to get the location of a pageitem when there are pageitems with same UID?

    There are two text frames with same UID but on different pages( also defferent spreads ). What I want to know is how I can get the location of them both.
    The following code can only get the location of the first frame because the second frame has the same UIDRef with the first one(because they are in one document with same UID) .
        InterfacePtr<IGeometry> splineGeo(ItemRef, IID_IGEOMETRY);
        PMMatrix itemPMMatrix = ::InnerToPasteboardMatrix( splineGeo );
        PMRect  itemPMRect = itemGeo->GetStrokeBoundingBox( itemPMMatrix );
    Is there any way I can get the second frame location?
    Thanks a lot.

    No.
    Just copy the pageitems from master page to document page.

  • How to get nodes and its attributes of an XML file usiong DOM parsing?

    how to get nodes and its attributes of an XML file usiong DOM parsing?
    i am new to XML parsing.......
    Thanking you........

    import org.w3c.dom.Document;
    import org.w3c.dom.*;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;      ...
    //Setup the document
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
         DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
         Document doc = docBuilder.parse (new File("MY_XML_FILE.xml"));
    //get elemets by name
         String elementValue = doc.getElementsByTagName("MY_ELEMENT").item(0).getTextContent();
    //This method can return multiple nodes, in this instance I get item(0) , first nodeRead the api for other methods of getting data.

  • GET Node in logical database to be executed on a condition

    Dear Friends,
    I have used GET NODE (get pernr) to extract data from HR LDB- PNP.
    Using HR Report Category I have customized selection screen so that user cannot enter employee number (so that he can only see his payslip only) but can select just the period.
    So in the calling program I want "GET pernr" to execute only when pernr = sy-uname. How can I do it???
    Thanks,
    Amit

    Hi ,
    After the Get event ,put a check statement on node data like
    Get Pernr.
    Check pernr-pernr = sy-uname.

  • How to get the location of the browser?(pt_BR, en_US, es_ES...)

    How to get the location of the browser?
    example: pt_BR, en_US, es_ES...

    Hi Eduardo Cordeiro,
    Sorry in reaching you late...I was out on a trip...
    You need to put the javascript in your Flex application html wrapper file ...in which your  Flex application SWF is embedded.
    Write the Javascript function in your html file as below :
    function getBrowserLanguage()
      var browserLanguage = navigator.browserLanguage;
      return browserLanguage;
    //In your mxml File you can access the JavaScript function in your MXML as below:
    var browserLang:String  = ExternalInterface.call('getBrowserType');
    If this post answers your question or helps, please kindly mark it as such.
    Thanks,
    Bhasker Chari

  • Help setting node height in a JTree

    I have a JTree in which i would like to make the font of the nodes somewhat large (size 16). However, by setting the node's font to this size, i notice that the top and bottom of the node values are truncated. I was wondering how i could increase each node's height so that the value can be easily readable. I have tried extending DefaultTreeCellRenderer and setting the preferred and minimun sizes. I have also tried using a panel as my TreeCellRenderer and setting its sizes. Neither of these attempts worked. So, does anyone out there know how to set the node height or node spacing of a JTree?

    When I set the font on the JTable, everything seems to scale well.

Maybe you are looking for

  • Partial Paging on Report Regions

    I haven't seem a large use of Partial Paging on Report regions on any of the example packaged application Is there a way I can implement partial paging on a subset of a report region ? e.g. I have a grid like the following project 1 task 1 task 2 pro

  • Test stand design for high speed brushless dc servo motor efficiency testing

    We are in the process of designing two test stands around the brushless dc servo motor in the attached specifications.  The first we would like to operate using Labview and a PXI-7352 controller.  The second will be a real time configuration.  The mo

  • TS1702 network error with facebook app loading newsfeed

    Network error with facebook app loading newsfeed?

  • Nokia 5310 Keypad problem

    My keypad is not reponding, as a result of which my phone is locked(keypad lock) and i am unable to unlock it. My mobile is just 3 months old. Does anybody else also facing similar kind of problems??? Plss help

  • Getting admin control of a used computer

    We purchased a G5 from Epay not long ago, and are having trouble with the admin part of it. The PO had upgraded some of the hardware and installed Leopard (came with Tiger I believe). When he sold it to us, he claimed he "reimaged" it so it was clean