Example usage for javax.swing.tree DefaultTreeSelectionModel setSelectionMode

List of usage examples for javax.swing.tree DefaultTreeSelectionModel setSelectionMode

Introduction

In this page you can find the example usage for javax.swing.tree DefaultTreeSelectionModel setSelectionMode.

Prototype

public void setSelectionMode(int mode) 

Source Link

Document

Sets the selection model, which must be one of SINGLE_TREE_SELECTION, CONTIGUOUS_TREE_SELECTION or DISCONTIGUOUS_TREE_SELECTION.

Usage

From source file:org.intermine.modelviewer.swing.ModelViewer.java

/**
 * Lays out the components within this panel and wires up the relevant
 * event listeners./*from  w w  w.  jav a  2  s .  c  o m*/
 */
private void init() {

    FileFilter xmlFilter = new XmlFileFilter();
    projectFileChooser = new JFileChooser();
    projectFileChooser.addChoosableFileFilter(xmlFilter);
    projectFileChooser.setAcceptAllFileFilterUsed(false);
    projectFileChooser.setFileFilter(xmlFilter);

    File lastProjectFile = MineManagerBackingStore.getInstance().getLastProjectFile();
    if (lastProjectFile != null) {
        projectFileChooser.setSelectedFile(lastProjectFile);
    }

    initButtonPanel();

    classTreeModel = new ClassTreeModel();
    classTree = new JTree(classTreeModel);
    classTree.setCellRenderer(new ClassTreeCellRenderer());
    classTree.setRootVisible(false);
    classTree.setShowsRootHandles(true);

    Box vbox = Box.createVerticalBox();
    vbox.add(new JScrollPane(classTree));
    vbox.add(buttonPanel);

    DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel();
    selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    classTree.setSelectionModel(selectionModel);

    classTree.addTreeSelectionListener(new ClassTreeSelectionListener());

    attributeTableModel = new AttributeTableModel();
    attributeTable = new AttributeTable(attributeTableModel);

    referenceTableModel = new ReferenceTableModel();
    referenceTable = new ReferenceTable(referenceTableModel);

    graphModel = new mxGraphModel();
    graph = new CustomisedMxGraph(graphModel);

    graphComponent = new mxGraphComponent(graph);
    graphComponent.setEscapeEnabled(true);

    JTabbedPane tableTab = new JTabbedPane(SwingConstants.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
    tableTab.add(Messages.getMessage("tab.attributes"), new JScrollPane(attributeTable));
    tableTab.add(Messages.getMessage("tab.references"), new JScrollPane(referenceTable));

    JSplitPane rightSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tableTab, graphComponent);

    JSplitPane mainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, vbox, rightSplit);

    setOpaque(true);
    setLayout(new BorderLayout());
    add(mainSplit, BorderLayout.CENTER);

    rightSplit.setDividerLocation(150);
    mainSplit.setDividerLocation(200);

}