How to use double-click to make JTree nodes editable

Posted on 2006-05-24
Last Modified: 2008-01-09
I'm having some difficulties making my JTree component work as I prefer. I have created a JTree with nodes consisting of four Jlabel components. When the user double-clicks on a node, I want it to become editable. My problem is that by default a node in a JTree is editable when a user clicks the node just once. This makes it imipossible to select a node without making it editable. Does anyone know any good way to handle this, so the nodes in the tree only is editable when the user double-clicks it. I am looking for something similar like the method SetToggleClickCount(), but havent found anything that works the way I prefer so far.

Please help me, I have spent way too much time trying to solve this!!

Thanks in advance,

Question by:nesnemis
    LVL 12

    Accepted Solution

    Do you have seen here?

    You must build your own selectionModel.

    Bye, Giant.
    LVL 1

    Assisted Solution

    LVL 14

    Assisted Solution

    listen to mouse events and on double click occurence, use this method to start editing a node

     void startEditingAtPath(TreePath path)
              Selects the node identified by the specified path and initiates editing.
    LVL 12

    Expert Comment

    link allready posted (sun book)
    LVL 3

    Assisted Solution

    LVL 1

    Expert Comment

    sorry Giant2
    i opened and i copy it by mistake

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Suggested Solutions

    INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
    After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
    This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now