Java Code Examples for javax.swing.TransferHandler#exportAsDrag()

The following examples show how to use javax.swing.TransferHandler#exportAsDrag() . 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: TableDNDRecognizer.java    From nextreports-designer with Apache License 2.0 6 votes vote down vote up
public void mouseDragged(MouseEvent ev) {
    Point p = ev.getPoint();
    if (!recognized
            && ev.isShiftDown()
            && ((Math.abs(pressedPoint.x - p.x) > 5) || (Math
                    .abs(pressedPoint.y - p.y) > 5))) {
        dragged = true;
        recognized = true;
        JComponent c = (JComponent) ev.getSource();
        TransferHandler th = c.getTransferHandler();
        if (th != null) {
            th.exportAsDrag(c, ev, ev.isAltDown() ? 
                    DnDConstants.ACTION_COPY : DnDConstants.ACTION_MOVE);
        }
    }
}
 
Example 2
Source File: MTransferableLabel.java    From javamelody with Apache License 2.0 5 votes vote down vote up
@Override
public void mouseDragged(MouseEvent e) {
	if (firstMouseEvent != null) {
		e.consume();
		final int dx = Math.abs(e.getX() - firstMouseEvent.getX());
		final int dy = Math.abs(e.getY() - firstMouseEvent.getY());
		if (dx > 5 || dy > 5) {
			final JComponent c = (JComponent) e.getSource();
			final TransferHandler handler = c.getTransferHandler();
			handler.exportAsDrag(c, firstMouseEvent, TransferHandler.COPY);
			firstMouseEvent = null;
		}
	}
}
 
Example 3
Source File: DragHandler.java    From niftyeditor with Apache License 2.0 5 votes vote down vote up
@Override
public void mousePressed(MouseEvent e) {
   
        NWidget c = (NWidget) e.getSource();
        TransferHandler handler = c.getTransferHandler();
        handler.exportAsDrag(c, e, TransferHandler.COPY); 
       
}
 
Example 4
Source File: GuiSelectionListener.java    From niftyeditor with Apache License 2.0 5 votes vote down vote up
public final void startDrag(MouseEvent e) {
    if(enable){
        if (!(this.getSelected() instanceof GScreen) && !(this.getSelected() instanceof GLayer)) {
            JPanel c = (JPanel) e.getComponent();
            TransferHandler handler = c.getTransferHandler();
            handler.exportAsDrag(c, e, TransferHandler.MOVE);
            this.niftyView.getDDManager().startDrag(this.getSelected());
        }
    }
  
}
 
Example 5
Source File: Tree.java    From Spark with Apache License 2.0 5 votes vote down vote up
/**
    * Handles drag and drop.
    *
    * @param e - the mousedragged event to handle drag and drop from.
    */
   @Override
public void mouseDragged(MouseEvent e) {
       final JComponent c = (JComponent)e.getSource();
       JiveTreeNode node = (JiveTreeNode)getLastSelectedPathComponent();
       if (node == null) {
           return;
       }
       if (node.isLeaf()) {
           TransferHandler handler = c.getTransferHandler();
           handler.exportAsDrag(c, e, TransferHandler.COPY);
       }
   }