Java Code Examples for javax.swing.JTree#setTransferHandler()

The following examples show how to use javax.swing.JTree#setTransferHandler() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PvExplorer.java    From AndrOBD with GNU General Public License v3.0 6 votes vote down vote up
public PvExplorer(ProcessVar pv)
{
	setDividerSize(2);
	setPreferredSize(new Dimension(640, 480));

	pvTree = new JTree(new PvTreeNode(pv));
	pvTree.getSelectionModel().addTreeSelectionListener(this);
	pvTree.setDragEnabled(true);
	pvTree.setDropMode(DropMode.ON_OR_INSERT);
	pvTree.setTransferHandler(xferHdlr);

	pvTable = new PvTable(pv);
	pvTable.setDragEnabled(true);
	pvTable.setDropMode(DropMode.ON_OR_INSERT);
	pvTable.addMouseListener(tblMouseLstnr);
	pvTable.setTransferHandler(xferHdlr);

	JScrollPane spPvTree = new JScrollPane(pvTree);
	add(spPvTree, JSplitPane.LEFT);
	JScrollPane spPvTable = new JScrollPane(pvTable);
	add(spPvTable, JSplitPane.RIGHT);
}
 
Example 2
Source File: LastNodeLowerHalfDrop.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private JScrollPane getContent() {
    jTree = new JTree(getTreeModel());
    jTree.setRootVisible(false);
    jTree.setDragEnabled(true);
    jTree.setDropMode(DropMode.INSERT);
    jTree.setTransferHandler(new TreeTransferHandler());
    jTree.getSelectionModel().setSelectionMode(
            TreeSelectionModel.SINGLE_TREE_SELECTION);
    expandTree(jTree);
    return new JScrollPane(jTree);
}
 
Example 3
Source File: TreeView.java    From RobotBuilder with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public TreeView(Palette palette) {
    this.palette = palette;

    tree = new JTree(palette.getPaletteModel()) {
        @Override
        public String getToolTipText(MouseEvent e) {
            try {
                TreePath path = getClosestPathForLocation(e.getX(), e.getY());
                return ((PaletteComponent) ((DefaultMutableTreeNode) path.getLastPathComponent()).getUserObject()).getHelp();
            } catch (ClassCastException ex) { // Ignore folders
                return null;
            }
        }
    };
    tree.setRootVisible(false);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setTransferHandler(new PaletteTreeTransferHandler(tree.getTransferHandler()));
    tree.setDragEnabled(true);
    ToolTipManager.sharedInstance().registerComponent(tree);
    tree.addTreeSelectionListener(this);

    for (int i = 0; i < tree.getRowCount(); i++) {
        tree.expandRow(i);
    }
    setLayout(new BorderLayout());
    add(tree, BorderLayout.CENTER);
}
 
Example 4
Source File: FilesTree.java    From android-classyshark with Apache License 2.0 5 votes vote down vote up
public FilesTree(ViewerController viewerPanel) {
    this.viewerController = viewerPanel;
    treeModel = new DefaultTreeModel(new DefaultMutableTreeNode());
    jTree = new JTree(treeModel);
    jTree.setDragEnabled(true);
    jTree.setTransferHandler(new FileTransferHandler(viewerController));
    jTree.setCellRenderer(new CellRenderer());
    configureJTree(jTree);
    GuiMode.getTheme().applyTo(jTree);
}
 
Example 5
Source File: MethodsCountPanel.java    From android-classyshark with Apache License 2.0 5 votes vote down vote up
private void setup() {
    this.setLayout(new BorderLayout());
    treeModel = new DefaultTreeModel(new DefaultMutableTreeNode(null));
    jTree = new JTree(treeModel);
    jTree.setRootVisible(false);
    jTree.setCellRenderer(new CellRenderer());
    theme.applyTo(jTree);

    DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) jTree.getCellRenderer();

    cellRenderer.setFont(new Font("Monospaced", Font.PLAIN, 20));
    jTree.setCellRenderer(cellRenderer);
    jTree.addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            Object selection = jTree.getLastSelectedPathComponent();
            DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode)selection;
            ClassNode node = (ClassNode) defaultMutableTreeNode.getUserObject();
            viewerController.onSelectedMethodCount(node);
        }
    });

    JScrollPane jScrollPane = new JScrollPane(jTree);
    this.setBorder(new EmptyBorder(0,0,0,0));
    this.add(jScrollPane, BorderLayout.CENTER);
    theme.applyTo(jScrollPane);

    jTree.setDragEnabled(true);
    jTree.setTransferHandler(new FileTransferHandler(viewerController));
}
 
Example 6
Source File: TreePanel.java    From nmonvisualizer with Apache License 2.0 4 votes vote down vote up
public TreePanel(NMONVisualizerGui gui) {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode(ROOT_NAME);

    tree = new JTree(root);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setCellRenderer(new TreeCellRenderer());

    setViewportView(tree);

    // make sure panel takes up entire parent, but the actual tree is offset slightly
    setBorder(null);
    tree.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));

    // data changes modify the tree
    gui.addDataSetListener(this);

    tree.addMouseListener(new TreeMouseListener(gui, tree));

    tree.setDragEnabled(true);
    tree.setTransferHandler(new TreeTransferHandler(gui));

    tree.setCellRenderer(new TreeCellRenderer());

    ToolTipManager.sharedInstance().registerComponent(tree);
}