Example usage for java.awt.dnd DragSource createDefaultDragGestureRecognizer

List of usage examples for java.awt.dnd DragSource createDefaultDragGestureRecognizer

Introduction

In this page you can find the example usage for java.awt.dnd DragSource createDefaultDragGestureRecognizer.

Prototype


public DragGestureRecognizer createDefaultDragGestureRecognizer(Component c, int actions,
        DragGestureListener dgl) 

Source Link

Document

Creates a new DragGestureRecognizer that implements the default abstract subclass of DragGestureRecognizer for this DragSource , and sets the specified Component and DragGestureListener on the newly created object.

Usage

From source file:org.jas.dnd.FileDragSource.java

public static void addDragSource(Component c, FileSelection modelSelection) {
    DragSource dragSource = new DragSource();
    FileDragSource dgl = new FileDragSource(dragSource, modelSelection);
    // Do not change ACTION_COPY or else only pain and misery will follow you until the end of time. JAVA DnDrops sux.
    // Big Time/* ww  w  .  ja  v  a  2s. com*/
    dragSource.createDefaultDragGestureRecognizer(c, DnDConstants.ACTION_COPY, dgl);
}

From source file:org.rdv.ui.ChannelListPanel.java

/**
 * Create the channel tree panel.// w ww  .j a  v a2s  . c  om
 * 
 * @return  the component containing the channel tree
 */
private JComponent createTreePanel() {
    treeModel = new ChannelTreeModel();
    treeModel.addPropertyChangeListener(new FilterPropertyChangeListener());

    tree = new JTree(treeModel);
    tree.setRootVisible(false);
    tree.setShowsRootHandles(true);
    tree.setExpandsSelectedPaths(true);
    tree.setCellRenderer(new ChannelTreeCellRenderer());
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    tree.addTreeSelectionListener(new ChannelTreeSelectionListener());
    tree.addMouseListener(new ChannelTreeMouseListener());
    tree.setBorder(new EmptyBorder(0, 5, 5, 5));

    JScrollPane treeView = new JScrollPane(tree);
    treeView.setBorder(null);
    treeView.setViewportBorder(null);

    tree.setDragEnabled(true);
    tree.setTransferHandler(new ChannelTransferHandler());

    DragSource dragSource = DragSource.getDefaultDragSource();
    dragSource.createDefaultDragGestureRecognizer(tree, DnDConstants.ACTION_LINK,
            new ChannelDragGestureListener());

    return treeView;
}

From source file:org.rdv.ui.DataPanelContainer.java

/**
 * Add a data panel UI component to this container.
 * /* w  ww .j a  va 2 s.com*/
 * @param component  the UI component to add
 * @since            1.1
 */
public void addDataPanel(JComponent component) {
    Integer position = previousPositions.get(component);
    if (position == null || position < 0 || position > dataPanels.size()) {
        dataPanels.add(component);
    } else {
        dataPanels.add(position, component);
    }

    DragSource dragSource = DragSource.getDefaultDragSource();
    DragGestureRecognizer dragGesture = dragSource.createDefaultDragGestureRecognizer(component,
            DnDConstants.ACTION_MOVE, this);
    dragGestures.put(component, dragGesture);

    layoutDataPanels();

    log.info("Added data panel to container (total=" + dataPanels.size() + ").");
}

From source file:unikn.dbis.univis.explorer.VExplorer.java

License:asdf

private void initDragAndDrop() {
    DragSource dragSource = DragSource.getDefaultDragSource();
    dragSource.addDragSourceListener(tree);
    dragSource.createDefaultDragGestureRecognizer(tree, DnDConstants.ACTION_COPY, tree);
}