Example usage for java.awt.dnd DragGestureEvent getComponent

List of usage examples for java.awt.dnd DragGestureEvent getComponent

Introduction

In this page you can find the example usage for java.awt.dnd DragGestureEvent getComponent.

Prototype


public Component getComponent() 

Source Link

Document

Returns the Component associated with this DragGestureEvent .

Usage

From source file:ComplexExample.java

public void dragGestureRecognized(DragGestureEvent event) {
    Cursor cursor = null;/*  w  ww  . j av a 2 s  .co m*/
    JPanel panel = (JPanel) event.getComponent();

    Color color = panel.getBackground();
    if (event.getDragAction() == DnDConstants.ACTION_COPY) {
        cursor = DragSource.DefaultCopyDrop;
    }
    event.startDrag(cursor, new TransferableColor(color));
}

From source file:de.tor.tribes.ui.algo.AttackTimePanel.java

@Override
public void dragGestureRecognized(DragGestureEvent dge) {
    TimeSpan span = null;//from   w w  w  .  j  a  va 2  s  . co  m
    if (dge.getComponent().equals(jLabel5)) {
        span = getSendSpan();
    } else if (dge.getComponent().equals(jLabel6)) {
        span = getArriveSpan();
    }
    if (span != null) {
        dge.startDrag(null, new StringSelection(span.toPropertyString()), this);
    }
}