Example usage for javax.swing JTree addMouseListener

List of usage examples for javax.swing JTree addMouseListener

Introduction

In this page you can find the example usage for javax.swing JTree addMouseListener.

Prototype

public synchronized void addMouseListener(MouseListener l) 

Source Link

Document

Adds the specified mouse listener to receive mouse events from this component.

Usage

From source file:org.richie.codeGen.ui.CodeGenMainUI.java

/**
 * @param list/*from  w  ww .j a  va  2s  .co  m*/
 * @return
 */
private JTree initTreeData(List<Table> list) {
    TableTreeNode root = null;
    if (list == null || list.size() == 0) {
        root = new TableTreeNode("");
    } else {
        root = new TableTreeNode(list.get(0).getDataBaseCode() + ":" + list.get(0).getDataBaseName());
        for (Table table : list) {
            list.get(0).getDataBaseName();
            TableTreeNode node = new TableTreeNode(table);
            root.add(node);
            List<Column> columnList = table.getFields();
            for (Column column : columnList) {
                TableTreeNode columnNode = new TableTreeNode(column);
                node.add(columnNode);
            }
        }
    }
    JTree newTree = new JTree(root);
    newTree.setCellRenderer(new TableTreeRender());
    newTree.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent me) {
            doMouseClicked(me);
        }

    });
    return newTree;
}