TreeTable in Java using SwingX

TreeTable is a combination of Tree and Table. It can be very nice component when you want to display tabular data in a hierarchical manner. Last week when I was looking for a component that can be used to implement TreeTable, I came across JXTreeTable. It is a component of SwingX package by SwingLabs.


Using JXTreeTable we can create TreeTable very easily. Only difficult part is creating the DataModel to match with our requirement.

This is the sample application, I did for my HCI assignment with contains code for how to use  JXTreeTable. You can download SwingX here. Hope this will be helpful for you.


Reader Comments

i try your code
i add a void main method in the TreeTableDemo, launch the main and it's displayed only 2 rows incoming node and expense node
please tell me what i have done wrong

Thanks for sharing, really helps.

Could you make an example using Treetable in netbeans?.I have tried to use your library but it doesn't work.

I am looking forward your message.

is any example for creating TreeTable from database

i have download this tutorial and import to eclipse ide and run and click on the tree table button but in showing frame(tree table Demo) no exist any tree or tree children only income and expenses rows. Why?. And i have one question: is any way to create with swingX tree table from database.Thanks an advance.

For those that are asking about the two-row-only TreeTable add the following line after adding all the nodes te "binTree" object in the TreeTableDemo class constructor:


For me was a great example for using a JXTreeTable.

Thank you very much!


Will get you handles to expand a row.

i add this before the constrtuctor, stay great.
binTree.addMouseListener(new MouseAdapter() {

public void mouseClicked(MouseEvent e) {

JXTreeTable bin = (JXTreeTable) e.getComponent();
if (bin.isCollapsed(bin.getSelectedRow())) {
} else {


Tribune to Heros

Tribune to Heros
We will never forget the sacrifices you made to protect our country....


Get Google Toolbar Button

Enter your email address:

Delivered by FeedBurner