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

📄 dragsourcecontext.java

📁 JAVA基本类源代码,大家可以学习学习!
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    }    /**     * Notifies the peer that the <code>Transferable</code>'s     * <code>DataFlavor</code>s have changed.     */    public void transferablesFlavorsChanged() {	if (peer != null) peer.transferablesFlavorsChanged();    }    /**     * Calls <code>dragEnter</code> on the     * <code>DragSourceListener</code>s registered with this     * <code>DragSourceContext</code> and with the associated     * <code>DragSource</code>, and passes them the specified     * <code>DragSourceDragEvent</code>.     *     * @param dsde the <code>DragSourceDragEvent</code>     */    public void dragEnter(DragSourceDragEvent dsde) {        DragSourceListener dsl = listener;        if (dsl != null) {            dsl.dragEnter(dsde);        }        getDragSource().processDragEnter(dsde);	updateCurrentCursor(dsde.getDropAction(), dsde.getTargetActions(), ENTER);    }    /**     * Calls <code>dragOver</code> on the     * <code>DragSourceListener</code>s registered with this     * <code>DragSourceContext</code> and with the associated     * <code>DragSource</code>, and passes them the specified     * <code>DragSourceDragEvent</code>.     *     * @param dsde the <code>DragSourceDragEvent</code>     */    public void dragOver(DragSourceDragEvent dsde) {        DragSourceListener dsl = listener;        if (dsl != null) {            dsl.dragOver(dsde);        }        getDragSource().processDragOver(dsde);	updateCurrentCursor(dsde.getDropAction(), dsde.getTargetActions(), OVER);    }    /**     * Calls <code>dragExit</code> on the     * <code>DragSourceListener</code>s registered with this     * <code>DragSourceContext</code> and with the associated     * <code>DragSource</code>, and passes them the specified     * <code>DragSourceEvent</code>.     *     * @param dse the <code>DragSourceEvent</code>     */    public void dragExit(DragSourceEvent dse) {        DragSourceListener dsl = listener;        if (dsl != null) {            dsl.dragExit(dse);        }        getDragSource().processDragExit(dse);	updateCurrentCursor(DnDConstants.ACTION_NONE, DnDConstants.ACTION_NONE, DEFAULT);    }    /**     * Calls <code>dropActionChanged</code> on the     * <code>DragSourceListener</code>s registered with this     * <code>DragSourceContext</code> and with the associated     * <code>DragSource</code>, and passes them the specified     * <code>DragSourceDragEvent</code>.     *     * @param dsde the <code>DragSourceDragEvent</code>     */    public void dropActionChanged(DragSourceDragEvent dsde) {        DragSourceListener dsl = listener;        if (dsl != null) {            dsl.dropActionChanged(dsde);        }        getDragSource().processDropActionChanged(dsde);	updateCurrentCursor(dsde.getDropAction(), dsde.getTargetActions(), CHANGED);    }    /**     * Calls <code>dragDropEnd</code> on the     * <code>DragSourceListener</code>s registered with this     * <code>DragSourceContext</code> and with the associated     * <code>DragSource</code>, and passes them the specified     * <code>DragSourceDropEvent</code>.     *     * @param dsde the <code>DragSourceDropEvent</code>     */    public void dragDropEnd(DragSourceDropEvent dsde) {        DragSourceListener dsl = listener;        if (dsl != null) {            dsl.dragDropEnd(dsde);        }        getDragSource().processDragDropEnd(dsde);    }    /**     * Calls <code>dragMouseMoved</code> on the     * <code>DragSourceMotionListener</code>s registered with the     * <code>DragSource</code> associated with this     * <code>DragSourceContext</code>, and them passes the specified     * <code>DragSourceDragEvent</code>.     *     * @param dsde the <code>DragSourceDragEvent</code>     * @since 1.4     */    public void dragMouseMoved(DragSourceDragEvent dsde) {        getDragSource().processDragMouseMoved(dsde);    }    /**     * Returns the <code>Transferable</code> associated with     * this <code>DragSourceContext</code>.     *      * @return the <code>Transferable</code>     */    public Transferable getTransferable() { return transferable; }       /**     * If the default drag cursor behavior is active, this method     * sets the default drag cursor for the specified selected     * operation, supported actions and status, otherwise this     * method does nothing.     *      * @param dropOp the user's currently selected operation     * @param targetAct the current target's supported actions     * @param status the constant     */    protected synchronized void updateCurrentCursor(int dropOp, int targetAct, int status) {	// if the cursor has been previously set then dont do any defaults	// processing.	if (useCustomCursor) {	    return;	}	// do defaults processing	Cursor c = null;	switch (status) {	    default:		targetAct = DnDConstants.ACTION_NONE;	    case ENTER:	    case OVER:	    case CHANGED:		int    ra = dropOp & targetAct;		if (ra == DnDConstants.ACTION_NONE) { // no drop possible		    if ((dropOp & DnDConstants.ACTION_LINK) == DnDConstants.ACTION_LINK)		        c = DragSource.DefaultLinkNoDrop;		    else if ((dropOp & DnDConstants.ACTION_MOVE) == DnDConstants.ACTION_MOVE)		        c = DragSource.DefaultMoveNoDrop;		    else		        c = DragSource.DefaultCopyNoDrop;		} else { // drop possible		    if ((ra & DnDConstants.ACTION_LINK) == DnDConstants.ACTION_LINK)		        c = DragSource.DefaultLinkDrop;		    else if ((ra & DnDConstants.ACTION_MOVE) == DnDConstants.ACTION_MOVE)		        c = DragSource.DefaultMoveDrop;		    else		        c = DragSource.DefaultCopyDrop;		}	}        setCursorImpl(c);    }    private void setCursorImpl(Cursor c) {        if (cursor == null || !cursor.equals(c)) {            cursor = c;            if (peer != null) peer.setCursor(cursor);        }    }    /**     * Serializes this <code>DragSourceContext</code>. This method first     * performs default serialization. Next, this object's     * <code>Transferable</code> is written out if and only if it can be     * serialized. If not, <code>null</code> is written instead. In this case,     * a <code>DragSourceContext</code> created from the resulting deserialized     * stream will contain a dummy <code>Transferable</code> which supports no     * <code>DataFlavor</code>s. Finally, this object's     * <code>DragSourceListener</code> is written out if and only if it can be     * serialized. If not, <code>null</code> is written instead.     *     * @serialData The default serializable fields, in alphabetical order,     *             followed by either a <code>Transferable</code> instance, or     *             <code>null</code>, followed by either a     *             <code>DragSourceListener</code> instance, or     *             <code>null</code>.     * @since 1.4     */    private void writeObject(ObjectOutputStream s) throws IOException {        s.defaultWriteObject();        s.writeObject(SerializationTester.test(transferable)                      ? transferable : null);        s.writeObject(SerializationTester.test(listener)                      ? listener : null);    }    /**     * Deserializes this <code>DragSourceContext</code>. This method first     * performs default deserialization for all non-<code>transient</code>     * fields. This object's <code>Transferable</code> and     * <code>DragSourceListener</code> are then deserialized as well by using     * the next two objects in the stream. If the resulting     * <code>Transferable</code> is <code>null</code>, this object's     * <code>Transferable</code> is set to a dummy <code>Transferable</code>     * which supports no <code>DataFlavor</code>s.     *     * @since 1.4     */    private void readObject(ObjectInputStream s)        throws ClassNotFoundException, IOException    {        s.defaultReadObject();        transferable = (Transferable)s.readObject();        listener = (DragSourceListener)s.readObject();        // Implementation assumes 'transferable' is never null.        if (transferable == null) {            if (emptyTransferable == null) {                emptyTransferable = new Transferable() {                        public DataFlavor[] getTransferDataFlavors() {                            return new DataFlavor[0];                        }                        public boolean isDataFlavorSupported(DataFlavor flavor)                        {                            return false;                        }                        public Object getTransferData(DataFlavor flavor)                            throws UnsupportedFlavorException                        {                            throw new UnsupportedFlavorException(flavor);                        }                    };            }            transferable = emptyTransferable;        }    }    private static Transferable emptyTransferable;    /*     * fields     */    private transient DragSourceContextPeer peer;    /**     * The event which triggered the start of the drag.     *     * @serial     */    private DragGestureEvent    trigger;    /**     * The current drag cursor.     *     * @serial     */    private Cursor              cursor;    private transient Transferable      transferable;    private transient DragSourceListener    listener;    /**     * <code>true</code> if the custom drag cursor is used instead of the     * default one.     *     * @serial     */    private boolean useCustomCursor;    /**     * A bitwise mask of <code>DnDConstants</code> that represents the set of     * drop actions supported by the drag source for the drag operation associated     * with this <code>DragSourceContext.</code>       *     * @serial     */    private final int sourceActions;}

⌨️ 快捷键说明

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