src/macosx/classes/sun/lwawt/LWComponentPeer.java

Print this page




 968         return false;
 969     }
 970 
 971     @Override
 972     public final void applyShape(final Region shape) {
 973         synchronized (getStateLock()) {
 974             region = shape;
 975         }
 976         repaintParent(getBounds());
 977     }
 978 
 979     protected final Region getRegion() {
 980         synchronized (getStateLock()) {
 981             return region == null ? Region.getInstance(getSize()) : region;
 982         }
 983     }
 984 
 985     // DropTargetPeer Method
 986     @Override
 987     public void addDropTarget(DropTarget dt) {
 988         synchronized (dropTargetLock){






 989             // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only
 990             // if it's the first (or last) one for the component. Otherwise this call is a no-op.
 991             if (++fNumDropTargets == 1) {
 992                 // Having a non-null drop target would be an error but let's check just in case:
 993                 if (fDropTarget != null)
 994                     System.err.println("CComponent.addDropTarget(): current drop target is non-null.");
 995 
 996                 // Create a new drop target:
 997                 fDropTarget = CDropTarget.createDropTarget(dt, target, this);
 998             }
 999         }
1000     }

1001 
1002     // DropTargetPeer Method
1003     @Override
1004     public void removeDropTarget(DropTarget dt) {






1005         synchronized (dropTargetLock){
1006             // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only
1007             // if it's the first (or last) one for the component. Otherwise this call is a no-op.
1008             if (--fNumDropTargets == 0) {
1009                 // Having a null drop target would be an error but let's check just in case:
1010                 if (fDropTarget != null) {
1011                     // Dispose of the drop target:
1012                     fDropTarget.dispose();
1013                     fDropTarget = null;
1014                 } else
1015                     System.err.println("CComponent.removeDropTarget(): current drop target is null.");
1016             }
1017         }
1018     }

1019 
1020     // ---- PEER NOTIFICATIONS ---- //
1021 
1022     /**
1023      * Called when this peer's location has been changed either as a result
1024      * of target.setLocation() or as a result of user actions (window is
1025      * dragged with mouse).
1026      *
1027      * To be overridden in LWWindowPeer to update its GraphicsConfig.
1028      *
1029      * This method could be called on the toolkit thread.
1030      */
1031     protected final void handleMove(final int x, final int y,
1032                                     final boolean updateTarget) {
1033         if (updateTarget) {
1034             AWTAccessor.getComponentAccessor().setLocation(getTarget(), x, y);
1035         }
1036         postEvent(new ComponentEvent(getTarget(),
1037                                      ComponentEvent.COMPONENT_MOVED));
1038     }




 968         return false;
 969     }
 970 
 971     @Override
 972     public final void applyShape(final Region shape) {
 973         synchronized (getStateLock()) {
 974             region = shape;
 975         }
 976         repaintParent(getBounds());
 977     }
 978 
 979     protected final Region getRegion() {
 980         synchronized (getStateLock()) {
 981             return region == null ? Region.getInstance(getSize()) : region;
 982         }
 983     }
 984 
 985     // DropTargetPeer Method
 986     @Override
 987     public void addDropTarget(DropTarget dt) {
 988         LWWindowPeer winPeer = getWindowPeerOrSelf();
 989         if (winPeer != null && winPeer != this) {
 990             // We need to register the DropTarget in the
 991             // peer of the window ancestor of the component
 992             winPeer.addDropTarget(dt);
 993         } else {
 994             synchronized (dropTargetLock) {
 995                 // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only
 996                 // if it's the first (or last) one for the component. Otherwise this call is a no-op.
 997                 if (++fNumDropTargets == 1) {
 998                     // Having a non-null drop target would be an error but let's check just in case:
 999                     if (fDropTarget != null)
1000                         System.err.println("CComponent.addDropTarget(): current drop target is non-null.");
1001 
1002                     // Create a new drop target:
1003                     fDropTarget = CDropTarget.createDropTarget(dt, target, this);
1004                 }
1005             }
1006         }
1007     }
1008 
1009     // DropTargetPeer Method
1010     @Override
1011     public void removeDropTarget(DropTarget dt) {
1012         LWWindowPeer winPeer = getWindowPeerOrSelf();
1013         if (winPeer != null && winPeer != this) {
1014             // We need to unregister the DropTarget in the
1015             // peer of the window ancestor of the component
1016             winPeer.removeDropTarget(dt);
1017         } else {
1018             synchronized (dropTargetLock){
1019                 // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only
1020                 // if it's the first (or last) one for the component. Otherwise this call is a no-op.
1021                 if (--fNumDropTargets == 0) {
1022                     // Having a null drop target would be an error but let's check just in case:
1023                     if (fDropTarget != null) {
1024                         // Dispose of the drop target:
1025                         fDropTarget.dispose();
1026                         fDropTarget = null;
1027                     } else
1028                         System.err.println("CComponent.removeDropTarget(): current drop target is null.");
1029                 }
1030             }
1031         }
1032     }
1033 
1034     // ---- PEER NOTIFICATIONS ---- //
1035 
1036     /**
1037      * Called when this peer's location has been changed either as a result
1038      * of target.setLocation() or as a result of user actions (window is
1039      * dragged with mouse).
1040      *
1041      * To be overridden in LWWindowPeer to update its GraphicsConfig.
1042      *
1043      * This method could be called on the toolkit thread.
1044      */
1045     protected final void handleMove(final int x, final int y,
1046                                     final boolean updateTarget) {
1047         if (updateTarget) {
1048             AWTAccessor.getComponentAccessor().setLocation(getTarget(), x, y);
1049         }
1050         postEvent(new ComponentEvent(getTarget(),
1051                                      ComponentEvent.COMPONENT_MOVED));
1052     }