Implementing JTree || Customizing JTree in our own way

387 views Asked by At

I want to implement the JTree code into my custom style as shown in figure bellow. I want to design a JTree to be editable on real-time and dynamically store the data into a database.

When I want to add the child, as can be seen on figure, I want to choose from optiosn and make my JTree produce a child node as required.

When I add new node, enter the name and press "ENTER" then it should be saved as it is. So, I want my JTree to produce nodes as per requirement when needed and can be deleted from drop down menu when mouse is clicked on add_icon.

So, anybody please can u help me design my own module or API for such a JTree. please please. this is to be implemented on my project. So, need help very soon. I am doing my project on Netbeans 8.0.2 under swing application.

Jtree Implementation model

1

There are 1 answers

2
0xFF On

I can offer you add a button to each node of your JTree. It's possible if you redefine TreeCellRenderer and then attach it to JTree:

JTree tree = new JTree(rootNode);
CellRendererWithButton renderer = new CellRendererWithButton();
tree.setCellRenderer(renderer);

Here you can find an example how create your own CellRendererWithButton.