Lets see how we can modify nodes in the tree.

How to use it?

Here is another interesting thing about the JContextTree, making your own nodes without having all
the problems of the JTree. And more than that, this can handle dynamic node creation.
Thoses new nodes can also be handled by your own columns or popup items.

        //Manipulating sub nodes------------------------------------------------
        SubNodeGroup myGroup = buildSubNodeGroup();
//        tree.removeSubNodeGroup(myGroup);
//        tree.removeSubNodeGroup(0);
//        int nbgroups = tree.getSubNodeGroupCount();
//        int index = tree.getSubNodeGroupIndex(myGroup);
//        SubNodeGroup[] groups = tree.getSubNodeGroups();

public SubNodeGroup buildSubNodeGroup() {
        class TitleNode extends ContextTreeNode{

            String title = "";
            TitleNode(String title,LightContextTreeModel model){
                this.title = title;
            public Object getValue() {
                return title;

            public void setValue(Object obj) {                

            public Icon getIcon() {
                return IconBundle.EMPTY_ICON;

            public boolean isEditable() {
                return false;
        class TitleNodeGroup implements SubNodeGroup{

            public boolean isValid(Object target) {
                return (target instanceof MapLayer);

            public void installInNode(LightContextTreeModel model, ContextTreeNode node) {
                MapLayer layer = (MapLayer) node.getUserObject();
                TitleNode mynode = new TitleNode(layer.getTitle(),model);
                model.insetNodeInto(mynode, node, 0);

            public void removeForNode(LightContextTreeModel model, ContextTreeNode node) {
                int max = node.getChildCount();
                for(int i=0; i<max; i++){
                    ContextTreeNode aNode = (ContextTreeNode) node.getChildAt(i);
                    if( aNode instanceof TitleNode){
        return new TitleNodeGroup();