Skip to end of metadata
Go to start of metadata


As you can see the JContextTree isn't a JTree nore a JTable, It's a JXTeeTable from library SwingX.

This component is the second most important after the JMapPane.
This tree is an independent widget, it's also a bean, so you can add it in the Swing Palette of NetBeans Matisse WYSIWYG for example.


Complete demo class :

The JContextTree

Using the usuel constructor :

This way you will obtain a one column tree with no popup menu items.

Do I need to add the JContext to a ScrollPane?


No need. It's allready in one.

Manage the contexts :

The tree is independant, you have perhaps noticed that the JContextTree class is a frame class, you have no access to the tree model, the column model or the jpopupmenu. You perhaps think that will limit the possibilities to personalize the tree. Yes you're completely right! But that's hard work to keep everything related between the listeners, the drag&Drop suport and the different models. Beside the root component JXTreeTable so I decided (for integrity reason) to lock everything.

Once a MapContext is added in the tree, it will listen to it and update when needed, just manipulate the context like you always do and the tree will fallow.

There are plenty of methods to add/remove/access the contexts in the tree, here are some :

And there is an active context (with a little green icon on the tree) :

It can be used to see on wich context you're working on in your application.

Listen to the tree :

Two different listeners possibles.

listen to the contexts

code is better than explication

listen to the selection

code is better than explication

Copy/Cut/Paste/Delete/Duplicate and the Buffer functions

I take care to add those functions, can be usefull.

When you paste, sometimes the tree will have to "duplicate" the element (when copy/paste in the same context). To separate the origial from the copy he had a prefix to the name.

You also have differents methods :

  • No labels