javax.swing
static class: TransferHandler.SwingDropTarget [javadoc |
source]
java.lang.Object
java.awt.dnd.DropTarget
javax.swing.TransferHandler$SwingDropTarget
All Implemented Interfaces:
UIResource, Serializable, DropTargetListener
This is the default drop target for drag and drop operations if
one isn't provided by the developer.
DropTarget
only supports one
DropTargetListener and doesn't
function properly if it isn't set.
This class sets the one listener as the linkage of drop handling
to the
TransferHandler, and adds support for
additional listeners which some of the
ComponentUI
implementations install to manipulate a drop insertion location.
| Constructor: |
SwingDropTarget(Component c) {
super(c, COPY_OR_MOVE | LINK, null);
try {
// addDropTargetListener is overridden
// we specifically need to add to the superclass
super.addDropTargetListener(getDropTargetListener());
} catch (TooManyListenersException tmle) {}
}
|
| Methods from java.awt.dnd.DropTarget: |
|---|
|
addDropTargetListener, addNotify, clearAutoscroll, createDropTargetAutoScroller, createDropTargetContext, doSetDefaultActions, dragEnter, dragExit, dragOver, drop, dropActionChanged, getComponent, getDefaultActions, getDropTargetContext, getFlavorMap, initializeAutoscrolling, isActive, removeDropTargetListener, removeNotify, setActive, setComponent, setDefaultActions, setFlavorMap, updateAutoscroll |
| Methods from java.lang.Object: |
|---|
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from javax.swing.TransferHandler$SwingDropTarget Detail: |
public void addDropTargetListener(DropTargetListener dtl) throws TooManyListenersException {
// Since the super class only supports one DropTargetListener,
// and we add one from the constructor, we always add to the
// extended list.
if (listenerList == null) {
listenerList = new EventListenerList();
}
listenerList.add(DropTargetListener.class, dtl);
}
|
public void dragEnter(DropTargetDragEvent e) {
super.dragEnter(e);
if (listenerList != null) {
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length-2; i >=0; i-=2) {
if (listeners[i]==DropTargetListener.class) {
((DropTargetListener)listeners[i+1]).dragEnter(e);
}
}
}
}
|
public void dragExit(DropTargetEvent e) {
super.dragExit(e);
if (listenerList != null) {
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length-2; i >=0; i-=2) {
if (listeners[i]==DropTargetListener.class) {
((DropTargetListener)listeners[i+1]).dragExit(e);
}
}
}
}
|
public void dragOver(DropTargetDragEvent e) {
super.dragOver(e);
if (listenerList != null) {
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length-2; i >=0; i-=2) {
if (listeners[i]==DropTargetListener.class) {
((DropTargetListener)listeners[i+1]).dragOver(e);
}
}
}
}
|
public void drop(DropTargetDropEvent e) {
super.drop(e);
if (listenerList != null) {
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length-2; i >=0; i-=2) {
if (listeners[i]==DropTargetListener.class) {
((DropTargetListener)listeners[i+1]).drop(e);
}
}
}
}
|
public void dropActionChanged(DropTargetDragEvent e) {
super.dropActionChanged(e);
if (listenerList != null) {
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length-2; i >=0; i-=2) {
if (listeners[i]==DropTargetListener.class) {
((DropTargetListener)listeners[i+1]).dropActionChanged(e);
}
}
}
}
|
public void removeDropTargetListener(DropTargetListener dtl) {
if (listenerList != null) {
listenerList.remove(DropTargetListener.class, dtl);
}
}
|