src/java.desktop/share/classes/java/awt/dnd/DropTarget.java
Print this page
*** 205,237 ****
public synchronized void setComponent(Component c) {
if (component == c || component != null && component.equals(c))
return;
! Component old;
! ComponentPeer oldPeer = null;
! if ((old = component) != null) {
clearAutoscroll();
component = null;
!
! if (componentPeer != null) {
! oldPeer = componentPeer;
! removeNotify(componentPeer);
! }
!
old.setDropTarget(null);
}
if ((component = c) != null) try {
c.setDropTarget(this);
} catch (Exception e) { // undo the change
if (old != null) {
old.setDropTarget(this);
! addNotify(oldPeer);
}
}
}
/**
--- 205,231 ----
public synchronized void setComponent(Component c) {
if (component == c || component != null && component.equals(c))
return;
! final Component old = component;
! if (old != null) {
clearAutoscroll();
component = null;
! removeNotify();
old.setDropTarget(null);
}
if ((component = c) != null) try {
c.setDropTarget(this);
} catch (Exception e) { // undo the change
if (old != null) {
old.setDropTarget(this);
! addNotify();
}
}
}
/**
*** 495,522 ****
*
* Calling this method, other than to notify this DropTarget of the
* association of the ComponentPeer with the Component may result in
* a malfunction of the DnD system.
**********************************************************************
- *
- * @param peer The Peer of the Component we are associated with!
- *
*/
!
! public void addNotify(ComponentPeer peer) {
! if (peer == componentPeer) return;
componentPeer = peer;
! final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
for (Component c = component;
c != null && peer instanceof LightweightPeer; c = c.getParent()) {
peer = acc.getPeer(c);
}
if (peer instanceof DropTargetPeer) {
! nativePeer = peer;
((DropTargetPeer)peer).addDropTarget(this);
} else {
nativePeer = null;
}
}
--- 489,516 ----
*
* Calling this method, other than to notify this DropTarget of the
* association of the ComponentPeer with the Component may result in
* a malfunction of the DnD system.
**********************************************************************
*/
! public void addNotify() {
! final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
! ComponentPeer peer = acc.getPeer(component);
! if (peer == null || peer == componentPeer) {
! return;
! }
componentPeer = peer;
!
for (Component c = component;
c != null && peer instanceof LightweightPeer; c = c.getParent()) {
peer = acc.getPeer(c);
}
if (peer instanceof DropTargetPeer) {
! nativePeer = (DropTargetPeer) peer;
((DropTargetPeer)peer).addDropTarget(this);
} else {
nativePeer = null;
}
}
*** 531,549 ****
*
* Calling this method, other than to notify this DropTarget of the
* disassociation of the ComponentPeer from the Component may result in
* a malfunction of the DnD system.
**********************************************************************
- *
- * @param peer The Peer of the Component we are being disassociated from!
*/
! public void removeNotify(ComponentPeer peer) {
! if (nativePeer != null)
! ((DropTargetPeer)nativePeer).removeDropTarget(this);
!
! componentPeer = nativePeer = null;
synchronized (this) {
if (isDraggingInside) {
dragExit(new DropTargetEvent(getDropTargetContext()));
}
--- 525,542 ----
*
* Calling this method, other than to notify this DropTarget of the
* disassociation of the ComponentPeer from the Component may result in
* a malfunction of the DnD system.
**********************************************************************
*/
! public void removeNotify() {
! if (nativePeer != null) {
! nativePeer.removeDropTarget(this);
! }
! componentPeer = null;
! nativePeer = null;
synchronized (this) {
if (isDraggingInside) {
dragExit(new DropTargetEvent(getDropTargetContext()));
}
*** 835,845 ****
private transient ComponentPeer componentPeer;
/*
* That Component's "native" Peer
*/
! private transient ComponentPeer nativePeer;
/**
* Default permissible actions supported by this DropTarget.
*
--- 828,838 ----
private transient ComponentPeer componentPeer;
/*
* That Component's "native" Peer
*/
! private transient DropTargetPeer nativePeer;
/**
* Default permissible actions supported by this DropTarget.
*