src/share/classes/javax/swing/TransferHandler.java

Print this page




1251             if (listenerList != null) {
1252                 Object[] listeners = listenerList.getListenerList();
1253                 for (int i = listeners.length-2; i>=0; i-=2) {
1254                     if (listeners[i]==DropTargetListener.class) {
1255                         ((DropTargetListener)listeners[i+1]).dragOver(e);
1256                     }
1257                 }
1258             }
1259         }
1260 
1261         public void dragExit(DropTargetEvent e) {
1262             super.dragExit(e);
1263             if (listenerList != null) {
1264                 Object[] listeners = listenerList.getListenerList();
1265                 for (int i = listeners.length-2; i>=0; i-=2) {
1266                     if (listeners[i]==DropTargetListener.class) {
1267                         ((DropTargetListener)listeners[i+1]).dragExit(e);
1268                     }
1269                 }
1270             }








1271         }
1272 
1273         public void drop(DropTargetDropEvent e) {
1274             super.drop(e);
1275             if (listenerList != null) {
1276                 Object[] listeners = listenerList.getListenerList();
1277                 for (int i = listeners.length-2; i>=0; i-=2) {
1278                     if (listeners[i]==DropTargetListener.class) {
1279                         ((DropTargetListener)listeners[i+1]).drop(e);
1280                     }
1281                 }
1282             }
1283         }
1284 
1285         public void dropActionChanged(DropTargetDragEvent e) {
1286             super.dropActionChanged(e);
1287             if (listenerList != null) {
1288                 Object[] listeners = listenerList.getListenerList();
1289                 for (int i = listeners.length-2; i>=0; i-=2) {
1290                     if (listeners[i]==DropTargetListener.class) {


1541                 e.dropComplete(success);
1542                 cleanup(success);
1543             } else {
1544                 e.rejectDrop();
1545                 cleanup(false);
1546             }
1547         }
1548 
1549         public void dropActionChanged(DropTargetDragEvent e) {
1550             /*
1551              * Work-around for Linux bug where dropActionChanged
1552              * is called before dragEnter.
1553              */
1554             if (component == null) {
1555                 return;
1556             }
1557 
1558             handleDrag(e);
1559         }
1560 
1561         private void cleanup(boolean forDrop) {
1562             setComponentDropLocation(null, forDrop);
1563             if (component instanceof JComponent) {
1564                 ((JComponent)component).dndDone();
1565             }
1566 
1567             if (timer != null) {
1568                 timer.stop();
1569             }
1570 
1571             state = null;
1572             component = null;
1573             lastPosition = null;
1574         }
1575     }
1576 
1577     /**
1578      * This is the default drag handler for drag and drop operations that
1579      * use the <code>TransferHandler</code>.
1580      */
1581     private static class DragHandler implements DragGestureListener, DragSourceListener {




1251             if (listenerList != null) {
1252                 Object[] listeners = listenerList.getListenerList();
1253                 for (int i = listeners.length-2; i>=0; i-=2) {
1254                     if (listeners[i]==DropTargetListener.class) {
1255                         ((DropTargetListener)listeners[i+1]).dragOver(e);
1256                     }
1257                 }
1258             }
1259         }
1260 
1261         public void dragExit(DropTargetEvent e) {
1262             super.dragExit(e);
1263             if (listenerList != null) {
1264                 Object[] listeners = listenerList.getListenerList();
1265                 for (int i = listeners.length-2; i>=0; i-=2) {
1266                     if (listeners[i]==DropTargetListener.class) {
1267                         ((DropTargetListener)listeners[i+1]).dragExit(e);
1268                     }
1269                 }
1270             }
1271             if (!isActive()) {
1272                 // If the Drop target is inactive the dragExit will not be dispatched to the dtListener,
1273                 // so make sure that we clean up the dtListener anyway.
1274                 DropTargetListener dtListener = getDropTargetListener();
1275                     if (dtListener != null && dtListener instanceof DropHandler) {
1276                         ((DropHandler)dtListener).cleanup(false);
1277                     }
1278             }
1279         }
1280 
1281         public void drop(DropTargetDropEvent e) {
1282             super.drop(e);
1283             if (listenerList != null) {
1284                 Object[] listeners = listenerList.getListenerList();
1285                 for (int i = listeners.length-2; i>=0; i-=2) {
1286                     if (listeners[i]==DropTargetListener.class) {
1287                         ((DropTargetListener)listeners[i+1]).drop(e);
1288                     }
1289                 }
1290             }
1291         }
1292 
1293         public void dropActionChanged(DropTargetDragEvent e) {
1294             super.dropActionChanged(e);
1295             if (listenerList != null) {
1296                 Object[] listeners = listenerList.getListenerList();
1297                 for (int i = listeners.length-2; i>=0; i-=2) {
1298                     if (listeners[i]==DropTargetListener.class) {


1549                 e.dropComplete(success);
1550                 cleanup(success);
1551             } else {
1552                 e.rejectDrop();
1553                 cleanup(false);
1554             }
1555         }
1556 
1557         public void dropActionChanged(DropTargetDragEvent e) {
1558             /*
1559              * Work-around for Linux bug where dropActionChanged
1560              * is called before dragEnter.
1561              */
1562             if (component == null) {
1563                 return;
1564             }
1565 
1566             handleDrag(e);
1567         }
1568 
1569         void cleanup(boolean forDrop) {
1570             setComponentDropLocation(null, forDrop);
1571             if (component instanceof JComponent) {
1572                 ((JComponent)component).dndDone();
1573             }
1574 
1575             if (timer != null) {
1576                 timer.stop();
1577             }
1578 
1579             state = null;
1580             component = null;
1581             lastPosition = null;
1582         }
1583     }
1584 
1585     /**
1586      * This is the default drag handler for drag and drop operations that
1587      * use the <code>TransferHandler</code>.
1588      */
1589     private static class DragHandler implements DragGestureListener, DragSourceListener {