TreeEditor: editable tree GUI component

TreeEditor is a Java GUI component for editing tree structure.  It is a JScrollPane (as of TreeEditor ver. 0.1.0) derived and you can directly embed the component in your app.  I would suggest using JSplitPane.

First and foremost, load the TreeEditor-0.1.5 library (if you are using Maven) as follows.

        <dependency>
            <groupId>com.github.easai.utils</groupId>
            <artifactId>TreeEditor</artifactId>
            <version>0.1.6</version>
        </dependency>

Instantiate TreeEditor with a file name (or an empty string).    Initialize it by calling TreeEditor#init().  Here I put it in a JSplitPane and the TreeEditor will be resizable as the pane resizes.

    TreeEditor treeEditor = new TreeEditor("");

    JTextArea menuCode = new JTextArea();
    JTextArea listenerCode = new JTextArea();

    public void init() {
        treeEditor.init();

        JSplitPane horizPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
        horizPane.setLeftComponent(treeEditor);

        horizPane.setDividerLocation(500);
        JSplitPane rightPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        rightPane.setTopComponent(new JScrollPane(menuCode));
        rightPane.setBottomComponent(listenerCode);
        rightPane.setDividerLocation(500);

        horizPane.setRightComponent(rightPane);

        getContentPane().add(horizPane);

        setSize(1300, 900);
        setVisible(true);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }


Here is a screen shot of the app. The left pane contains the TreeEditor component. Now you can process any tree structured data from the editor.


Comments

Popular posts from this blog

Logging your Maven project with Logback

TreeEditor: Customizing Drag and Drop

Spring Tool Suite