Methods Summary |
---|
protected javax.swing.JComponent | getComponent(java.awt.event.MouseEvent e)
Object src = e.getSource();
if (src instanceof JComponent) {
JComponent c = (JComponent) src;
return c;
}
return null;
|
private static int | getMotionThreshold()
return DragSource.getDragThreshold();
|
private javax.swing.TransferHandler | getTransferHandler(java.awt.event.MouseEvent e)
JComponent c = getComponent(e);
return c == null ? null : c.getTransferHandler();
|
protected boolean | isDragPossible(java.awt.event.MouseEvent e)Determines if the following are true:
- the press event is located over a selection
- the dragEnabled property is true
- A TranferHandler is installed
This is implemented to check for a TransferHandler.
Subclasses should perform the remaining conditions.
JComponent c = getComponent(e);
return (c == null) ? true : (c.getTransferHandler() != null);
|
protected int | mapDragOperationFromModifiers(java.awt.event.MouseEvent e)
int mods = e.getModifiersEx();
if ((mods & InputEvent.BUTTON1_DOWN_MASK) != InputEvent.BUTTON1_DOWN_MASK) {
return TransferHandler.NONE;
}
JComponent c = getComponent(e);
TransferHandler th = c.getTransferHandler();
return SunDragSourceContextPeer.convertModifiersToDropAction(mods, th.getSourceActions(c));
|
public void | mouseClicked(java.awt.event.MouseEvent e)
|
public void | mouseDragged(java.awt.event.MouseEvent e)
if (dndArmedEvent != null) {
e.consume();
int action = mapDragOperationFromModifiers(e);
if (action == TransferHandler.NONE) {
return;
}
int dx = Math.abs(e.getX() - dndArmedEvent.getX());
int dy = Math.abs(e.getY() - dndArmedEvent.getY());
if ((dx > getMotionThreshold()) || (dy > getMotionThreshold())) {
// start transfer... shouldn't be a click at this point
JComponent c = getComponent(e);
TransferHandler th = c.getTransferHandler();
th.exportAsDrag(c, dndArmedEvent, action);
dndArmedEvent = null;
}
}
|
public void | mouseEntered(java.awt.event.MouseEvent e)
//dndArmedEvent = null;
|
public void | mouseExited(java.awt.event.MouseEvent e)
//if (dndArmedEvent != null && mapDragOperationFromModifiers(e) == TransferHandler.NONE) {
// dndArmedEvent = null;
//}
|
public void | mouseMoved(java.awt.event.MouseEvent e)
|
public void | mousePressed(java.awt.event.MouseEvent e)
dndArmedEvent = null;
if (isDragPossible(e) && mapDragOperationFromModifiers(e) != TransferHandler.NONE) {
dndArmedEvent = e;
e.consume();
}
|
public void | mouseReleased(java.awt.event.MouseEvent e)
dndArmedEvent = null;
|