⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dragsource.java

📁 JAVA基本类源代码,大家可以学习学习!
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);            DragSourceContext     dsc = createDragSourceContext(dscp,                                                                trigger,                                                                dragCursor,                                                                dragImage,                                                                imageOffset,                                                                transferable,                                                                dsl                                                                );                        if (dsc == null) {                throw new InvalidDnDOperationException();            }							                dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw        } catch (RuntimeException e) {            SunDragSourceContextPeer.setDragDropInProgress(false);            throw e;        }    }    /**     * Start a drag, given the <code>DragGestureEvent</code>      * that initiated the drag, the initial      * <code>Cursor</code> to use,     * the <code>Transferable</code> subject data      * of the drag, the <code>DragSourceListener</code>,      * and the <code>FlavorMap</code>.      * <P>     * @param trigger	     the <code>DragGestureEvent</code> that      * initiated the drag     * @param dragCursor     the initial <code>Cursor</code> or      * <code>null</code> for defaults     * @param transferable   the subject data of the drag     * @param dsl	     the <code>DragSourceListener</code>     * @param flavorMap	     the <code>FlavorMap to use or <code>null</code>     * <P>     * @throws <code>java.awt.dnd.InvalidDnDOperationException</code>      *    if the Drag and Drop     *    system is unable to initiate a drag operation, or if the user     *    attempts to start a drag while an existing drag operation      *    is still executing     */    public void startDrag(DragGestureEvent   trigger,			  Cursor	     dragCursor,			  Transferable	     transferable,			  DragSourceListener dsl,			  FlavorMap	     flavorMap) throws InvalidDnDOperationException {	startDrag(trigger, dragCursor, null, null, transferable, dsl, flavorMap);    }    /**     * Start a drag, given the <code>DragGestureEvent</code>      * that initiated the drag, the initial <code>Cursor</code>      * to use,     * the <code>Image</code> to drag,      * the offset of the <code>Image</code> origin      * from the hotspot of the <code>Cursor</code>     * at the instant of the trigger,     * the subject data of the drag, and      * the <code>DragSourceListener</code>.      * <P>     * @param trigger		the <code>DragGestureEvent</code> that initiated the drag     * @param dragCursor	the initial <code>Cursor</code> or <code>null</code> for defaults     * @param dragImage		the <code>Image</code> to drag or <code>null</code>     * @param dragOffset	the offset of the <code>Image</code> origin from the hotspot     *				of the <code>Cursor</code> at the instant of the trigger     * @param transferable	the subject data of the drag     * @param dsl		the <code>DragSourceListener</code>     * <P>     * @throws <code>java.awt.dnd.InvalidDnDOperationException</code>      *    if the Drag and Drop     *    system is unable to initiate a drag operation, or if the user     *    attempts to start a drag while an existing drag operation       *    is still executing     */    public void startDrag(DragGestureEvent   trigger,			  Cursor	     dragCursor,			  Image		     dragImage,			  Point		     dragOffset,			  Transferable	     transferable,			  DragSourceListener dsl) throws InvalidDnDOperationException {	startDrag(trigger, dragCursor, dragImage, dragOffset, transferable, dsl, null);    }    /**     * Start a drag, given the <code>DragGestureEvent</code>      * that initiated the drag, the initial      * <code>Cursor</code> to      * use,      * the <code>Transferable</code> subject data      * of the drag, and the <code>DragSourceListener</code>.      * <P>     * @param trigger		the <code>DragGestureEvent</code> that initiated the drag     * @param dragCursor	the initial <code>Cursor</code> or <code>null</code> for defaults     * @param transferable	the subject data of the drag     * @param dsl		the <code>DragSourceListener</code>     * <P>     * @throws <code>java.awt.dnd.InvalidDnDOperationException</code>      *    if the Drag and Drop     *    system is unable to initiate a drag operation, or if the user     *    attempts to start a drag while an existing drag operation      *    is still executing     */    public void startDrag(DragGestureEvent   trigger,			  Cursor	     dragCursor,			  Transferable	     transferable,			  DragSourceListener dsl) throws InvalidDnDOperationException {	startDrag(trigger, dragCursor, null, null, transferable, dsl, null);    }    /**     * Creates the <code>DragSourceContext</code> to handle this drag.     * <p>      * To incorporate a new <code>DragSourceContext</code>      * subclass, subclass <code>DragSource</code> and     * override this method.     * <p>     * If <code>dragImage</code> is <code>null</code>, no image is used      * to represent the drag over feedback for this drag operation, but      * <code>NullPointerException</code> is not thrown.     * <p>     * If <code>dsl</code> is <code>null</code>, no drag source listener      * is registered with the created <code>DragSourceContext</code>,       * but <code>NullPointerException</code> is not thrown.     * <p>     * If <code>dragCursor</code> is <code>null</code>, the default drag      * cursors are used for this drag operation.       * <code>NullPointerException</code> is not thrown.     *     * @param dscp          The <code>DragSourceContextPeer</code> for this drag     * @param dgl	    The <code>DragGestureEvent</code> that triggered the      *                      drag     * @param dragCursor    The initial <code>Cursor</code> to display     * @param dragImage	    The <code>Image</code> to drag or <code>null</code>     * @param imageOffset   The offset of the <code>Image</code> origin from the      *                      hotspot of the cursor at the instant of the trigger     * @param t             The subject data of the drag     * @param dsl	    The <code>DragSourceListener</code>     *      * @return the <code>DragSourceContext</code>     *      * @throws NullPointerException if <code>dscp</code> is <code>null</code>     * @throws NullPointerException if <code>dgl</code> is <code>null</code>     * @throws NullPointerException if <code>dragImage</code> is not      *    <code>null</code> and <code>imageOffset</code> is <code>null</code>     * @throws NullPointerException if <code>t</code> is <code>null</code>     * @throws IllegalArgumentException if the <code>Component</code>      *         associated with the trigger event is <code>null</code>.     * @throws IllegalArgumentException if the <code>DragSource</code> for the      *         trigger event is <code>null</code>.     * @throws IllegalArgumentException if the drag action for the     *         trigger event is <code>DnDConstants.ACTION_NONE</code>.     * @throws IllegalArgumentException if the source actions for the     *         <code>DragGestureRecognizer</code> associated with the trigger     *         event are equal to <code>DnDConstants.ACTION_NONE</code>.      */    protected DragSourceContext createDragSourceContext(DragSourceContextPeer dscp, DragGestureEvent dgl, Cursor dragCursor, Image dragImage, Point imageOffset, Transferable t, DragSourceListener dsl) {	return new DragSourceContext(dscp, dgl, dragCursor, dragImage, imageOffset, t, dsl);    }    /**     * This method returns the      * <code>FlavorMap</code> for this <code>DragSource</code>.     * <P>     * @return the <code>FlavorMap</code> for this <code>DragSource</code>     */    public FlavorMap getFlavorMap() { return flavorMap; }    /**     * Creates a new <code>DragGestureRecognizer</code>      * that implements the specified     * abstract subclass of      * <code>DragGestureRecognizer</code>, and      * sets the specified <code>Component</code>      * and <code>DragGestureListener</code> on      * the newly created object.     * <P>     * @param recognizerAbstractClass the requested abstract type     * @param actions		      the permitted source drag actions     * @param c			      the <code>Component</code> target      * @param dgl	 the <code>DragGestureListener</code> to notify     * <P>     * @return the new <code>DragGestureRecognizer</code> or <code>null</code>     *    if the <code>Toolkit.createDragGestureRecognizer</code> method     *    has no implementation available for      *    the requested <code>DragGestureRecognizer</code>     *    subclass and returns <code>null</code>     */    public DragGestureRecognizer createDragGestureRecognizer(Class recognizerAbstractClass, Component c, int actions, DragGestureListener dgl) {	return Toolkit.getDefaultToolkit().createDragGestureRecognizer(recognizerAbstractClass, this, c, actions, dgl);    }	    /**     * Creates a new <code>DragGestureRecognizer</code>      * that implements the default     * abstract subclass of <code>DragGestureRecognizer</code>     * for this <code>DragSource</code>,     * and sets the specified <code>Component</code>      * and <code>DragGestureListener</code> on the     * newly created object.      *     * For this <code>DragSource</code>      * the default is <code>MouseDragGestureRecognizer</code>.     * <P>     * @param c	      the <code>Component</code> target for the recognizer     * @param actions the permitted source actions     * @param dgl     the <code>DragGestureListener</code> to notify     * <P>     * @return the new <code>DragGestureRecognizer</code> or <code>null</code>     *    if the <code>Toolkit.createDragGestureRecognizer</code> method     *    has no implementation available for      *    the requested <code>DragGestureRecognizer</code>     *    subclass and returns <code>null</code>     */    public DragGestureRecognizer createDefaultDragGestureRecognizer(Component c, int actions, DragGestureListener dgl) {	return Toolkit.getDefaultToolkit().createDragGestureRecognizer(MouseDragGestureRecognizer.class, this, c, actions, dgl);    }    /**     * Adds the specified <code>DragSourceListener</code> to this     * <code>DragSource</code> to receive drag source events during drag     * operations intiated with this <code>DragSource</code>.     * If a <code>null</code> listener is specified, no action is taken and no     * exception is thrown.     *     * @param dsl the <code>DragSourceListener</code> to add     *     * @see      #removeDragSourceListener     * @see      #getDragSourceListeners     * @since 1.4     */    public void addDragSourceListener(DragSourceListener dsl) {	if (dsl != null) {            synchronized (this) {                listener = DnDEventMulticaster.add(listener, dsl);            }        }    }    /**     * Removes the specified <code>DragSourceListener</code> from this     * <code>DragSource</code>.      * If a <code>null</code> listener is specified, no action is taken and no     * exception is thrown.     * If the listener specified by the argument was not previously added to     * this <code>DragSource</code>, no action is taken and no exception     * is thrown.     *      * @param dsl the <code>DragSourceListener</code> to remove     *     * @see      #addDragSourceListener     * @see      #getDragSourceListeners     * @since 1.4     */    public void removeDragSourceListener(DragSourceListener dsl) {        if (dsl != null) {            synchronized (this) {                listener = DnDEventMulticaster.remove(listener, dsl);            }        }    }    /**     * Gets all the <code>DragSourceListener</code>s     * registered with this <code>DragSource</code>.     *     * @return all of this <code>DragSource</code>'s     *         <code>DragSourceListener</code>s or an empty array if no     *         such listeners are currently registered     *     * @see      #addDragSourceListener     * @see      #removeDragSourceListener     * @since    1.4     */    public DragSourceListener[] getDragSourceListeners() {        return (DragSourceListener[])getListeners(DragSourceListener.class);    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -