create Folder Node DefaultMutableTreeNode - Java Swing

Java examples for Swing:JTree

Description

create Folder Node DefaultMutableTreeNode

Demo Code


//package com.java2s;
import javax.swing.tree.DefaultMutableTreeNode;

public class Main {
    public static void main(String[] argv) throws Exception {
        String folderName = "java2s.com";
        System.out.println(createFolderNode(folderName));
    }/* w w  w .  j a  v  a 2 s .co  m*/

    static DefaultMutableTreeNode createFolderNode(final String folderName) {
        DefaultMutableTreeNode newFolder = new DefaultMutableTreeNode(
                folderName) {
            public boolean isLeaf() {
                return false;
            }
        };
        return newFolder;
    }
}

Related Tutorials