< prev index next >

src/java.desktop/share/classes/java/awt/dnd/DropTarget.java

Print this page




 482         flavorMap = fm == null ? SystemFlavorMap.getDefaultFlavorMap() : fm;
 483     }
 484 
 485     /**
 486      * Notify the DropTarget that it has been associated with a Component
 487      *
 488      **********************************************************************
 489      * This method is usually called from java.awt.Component.addNotify() of
 490      * the Component associated with this DropTarget to notify the DropTarget
 491      * that a ComponentPeer has been associated with that Component.
 492      *
 493      * Calling this method, other than to notify this DropTarget of the
 494      * association of the ComponentPeer with the Component may result in
 495      * a malfunction of the DnD system.
 496      **********************************************************************
 497      *
 498      * @param peer The Peer of the Component we are associated with!
 499      *
 500      */
 501 

 502     public void addNotify(ComponentPeer peer) {
 503         if (peer == componentPeer) return;
 504 
 505         componentPeer = peer;
 506 
 507         for (Component c = component;
 508              c != null && peer instanceof LightweightPeer; c = c.getParent()) {
 509             peer = c.getPeer();
 510         }
 511 
 512         if (peer instanceof DropTargetPeer) {
 513             nativePeer = peer;
 514             ((DropTargetPeer)peer).addDropTarget(this);
 515         } else {
 516             nativePeer = null;
 517         }
 518     }
 519 
 520     /**
 521      * Notify the DropTarget that it has been disassociated from a Component


 673 
 674             timer.setCoalesce(true);
 675             timer.setInitialDelay(initial.intValue());
 676 
 677             locn = p;
 678             prev = p;
 679 
 680             try {
 681                 hysteresis = ((Integer)t.getDesktopProperty("DnD.Autoscroll.cursorHysteresis")).intValue();
 682             } catch (Exception e) {
 683                 // ignore
 684             }
 685 
 686             timer.start();
 687         }
 688 
 689         /**
 690          * update the geometry of the autoscroll region
 691          */
 692 

 693         private void updateRegion() {
 694            Insets    i    = autoScroll.getAutoscrollInsets();
 695            Dimension size = component.getSize();
 696 
 697            if (size.width != outer.width || size.height != outer.height)
 698                 outer.reshape(0, 0, size.width, size.height);
 699 
 700            if (inner.x != i.left || inner.y != i.top)
 701                 inner.setLocation(i.left, i.top);
 702 
 703            int newWidth  = size.width -  (i.left + i.right);
 704            int newHeight = size.height - (i.top  + i.bottom);
 705 
 706            if (newWidth != inner.width || newHeight != inner.height)
 707                 inner.setSize(newWidth, newHeight);
 708 
 709         }
 710 
 711         /**
 712          * cause autoscroll to occur




 482         flavorMap = fm == null ? SystemFlavorMap.getDefaultFlavorMap() : fm;
 483     }
 484 
 485     /**
 486      * Notify the DropTarget that it has been associated with a Component
 487      *
 488      **********************************************************************
 489      * This method is usually called from java.awt.Component.addNotify() of
 490      * the Component associated with this DropTarget to notify the DropTarget
 491      * that a ComponentPeer has been associated with that Component.
 492      *
 493      * Calling this method, other than to notify this DropTarget of the
 494      * association of the ComponentPeer with the Component may result in
 495      * a malfunction of the DnD system.
 496      **********************************************************************
 497      *
 498      * @param peer The Peer of the Component we are associated with!
 499      *
 500      */
 501 
 502     @SuppressWarnings("deprecation")
 503     public void addNotify(ComponentPeer peer) {
 504         if (peer == componentPeer) return;
 505 
 506         componentPeer = peer;
 507 
 508         for (Component c = component;
 509              c != null && peer instanceof LightweightPeer; c = c.getParent()) {
 510             peer = c.getPeer();
 511         }
 512 
 513         if (peer instanceof DropTargetPeer) {
 514             nativePeer = peer;
 515             ((DropTargetPeer)peer).addDropTarget(this);
 516         } else {
 517             nativePeer = null;
 518         }
 519     }
 520 
 521     /**
 522      * Notify the DropTarget that it has been disassociated from a Component


 674 
 675             timer.setCoalesce(true);
 676             timer.setInitialDelay(initial.intValue());
 677 
 678             locn = p;
 679             prev = p;
 680 
 681             try {
 682                 hysteresis = ((Integer)t.getDesktopProperty("DnD.Autoscroll.cursorHysteresis")).intValue();
 683             } catch (Exception e) {
 684                 // ignore
 685             }
 686 
 687             timer.start();
 688         }
 689 
 690         /**
 691          * update the geometry of the autoscroll region
 692          */
 693 
 694         @SuppressWarnings("deprecation")
 695         private void updateRegion() {
 696            Insets    i    = autoScroll.getAutoscrollInsets();
 697            Dimension size = component.getSize();
 698 
 699            if (size.width != outer.width || size.height != outer.height)
 700                 outer.reshape(0, 0, size.width, size.height);
 701 
 702            if (inner.x != i.left || inner.y != i.top)
 703                 inner.setLocation(i.left, i.top);
 704 
 705            int newWidth  = size.width -  (i.left + i.right);
 706            int newHeight = size.height - (i.top  + i.bottom);
 707 
 708            if (newWidth != inner.width || newHeight != inner.height)
 709                 inner.setSize(newWidth, newHeight);
 710 
 711         }
 712 
 713         /**
 714          * cause autoscroll to occur


< prev index next >