Java Doc for DragSourceContext.java in  » 6.0-JDK-Core » AWT » java » awt » dnd » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » AWT » java.awt.dnd 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.awt.dnd.DragSourceContext

DragSourceContext
public class DragSourceContext implements DragSourceListener,DragSourceMotionListener,Serializable(Code)
The DragSourceContext class is responsible for managing the initiator side of the Drag and Drop protocol. In particular, it is responsible for managing drag event notifications to the and , and providing the Transferable representing the source data for the drag operation.

Note that the DragSourceContext itself implements the DragSourceListener and DragSourceMotionListener interfaces. This is to allow the platform peer (the DragSourceContextPeer instance) created by the DragSource to notify the DragSourceContext of state changes in the ongoing operation. This allows the DragSourceContext object to interpose itself between the platform and the listeners provided by the initiator of the drag operation.

By default, DragSourceContext sets the cursor as appropriate for the current state of the drag and drop operation. For example, if the user has chosen , and the pointer is over a target that accepts the move action, the default move cursor is shown. When the pointer is over an area that does not accept the transfer, the default "no drop" cursor is shown.

This default handling mechanism is disabled when a custom cursor is set by the DragSourceContext.setCursor method. When the default handling is disabled, it becomes the responsibility of the developer to keep the cursor up to date, by listening to the DragSource events and calling the setCursor() method. Alternatively, you can provide custom cursor behavior by providing custom implementations of the DragSource and the DragSourceContext classes.
See Also:   DragSourceListener
See Also:   DragSourceMotionListener
See Also:   DnDConstants
version:
   1.62, 06/05/07
since:
   1.2



Field Summary
final protected static  intCHANGED
     An int used by updateCurrentCursor() indicating that the user operation has changed.
final protected static  intDEFAULT
     An int used by updateCurrentCursor() indicating that the Cursor should change to the default (no drop) Cursor.
final protected static  intENTER
     An int used by updateCurrentCursor() indicating that the Cursor has entered a DropTarget.
final protected static  intOVER
     An int used by updateCurrentCursor() indicating that the Cursor is over a DropTarget.

Constructor Summary
public  DragSourceContext(DragSourceContextPeer dscp, DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point offset, Transferable t, DragSourceListener dsl)
     Called from DragSource, this constructor creates a new DragSourceContext given the DragSourceContextPeer for this Drag, the DragGestureEvent that triggered the Drag, the initial Cursor to use for the Drag, an (optional) Image to display while the Drag is taking place, the offset of the Image origin from the hotspot at the instant of the triggering event, the Transferable subject data, and the DragSourceListener to use during the Drag and Drop operation.
If DragSourceContextPeer is null NullPointerException is thrown.
If DragGestureEvent is null NullPointerException is thrown.
If Cursor is null no exception is thrown and the default drag cursor behavior is activated for this drag operation.
If Image is null no exception is thrown.
If Image is not null and the offset is null NullPointerException is thrown.
If Transferable is null NullPointerException is thrown.
If DragSourceListener is null no exception is thrown.
Parameters:
  dscp - the DragSourceContextPeer for this drag
Parameters:
  trigger - the triggering event
Parameters:
  dragCursor - the initial Cursor for this drag operationor null for the default cursor handling;see class level documentationfor more details on the cursor handling mechanism during drag and drop
Parameters:
  dragImage - the Image to drag (or null)
Parameters:
  offset - the offset of the image origin from the hotspot at theinstant of the triggering event
Parameters:
  t - the Transferable
Parameters:
  dsl - the DragSourceListener
throws:
  IllegalArgumentException - if the Component associatedwith the trigger event is null.
throws:
  IllegalArgumentException - if the DragSource for the trigger event is null.
throws:
  IllegalArgumentException - if the drag action for thetrigger event is DnDConstants.ACTION_NONE.
throws:
  IllegalArgumentException - if the source actions for theDragGestureRecognizer associated with the triggerevent are equal to DnDConstants.ACTION_NONE.

Method Summary
public synchronized  voidaddDragSourceListener(DragSourceListener dsl)
     Add a DragSourceListener to this DragSourceContext if one has not already been added.
public  voiddragDropEnd(DragSourceDropEvent dsde)
     Calls dragDropEnd on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDropEvent.
public  voiddragEnter(DragSourceDragEvent dsde)
     Calls dragEnter on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDragEvent.
public  voiddragExit(DragSourceEvent dse)
     Calls dragExit on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceEvent.
public  voiddragMouseMoved(DragSourceDragEvent dsde)
     Calls dragMouseMoved on the DragSourceMotionListeners registered with the DragSource associated with this DragSourceContext, and them passes the specified DragSourceDragEvent.
public  voiddragOver(DragSourceDragEvent dsde)
     Calls dragOver on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDragEvent.
public  voiddropActionChanged(DragSourceDragEvent dsde)
     Calls dropActionChanged on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDragEvent.
public  ComponentgetComponent()
     Returns the Component associated with this DragSourceContext.
public  CursorgetCursor()
     Returns the current drag Cursor.
public  DragSourcegetDragSource()
     Returns the DragSource that instantiated this DragSourceContext.
public  intgetSourceActions()
     Returns a bitwise mask of DnDConstants that represent the set of drop actions supported by the drag source for the drag operation associated with this DragSourceContext.
public  TransferablegetTransferable()
     Returns the Transferable associated with this DragSourceContext.
public  DragGestureEventgetTrigger()
     Returns the DragGestureEvent that initially triggered the drag.
public synchronized  voidremoveDragSourceListener(DragSourceListener dsl)
     Removes the specified DragSourceListener from this DragSourceContext.
public synchronized  voidsetCursor(Cursor c)
     Sets the cursor for this drag operation to the specified Cursor.
public  voidtransferablesFlavorsChanged()
     Notifies the peer that the Transferable's DataFlavors have changed.
protected synchronized  voidupdateCurrentCursor(int sourceAct, int targetAct, int status)
     If the default drag cursor behavior is active, this method sets the default drag cursor for the specified actions supported by the drag source, the drop target action, and status, otherwise this method does nothing.

Field Detail
CHANGED
final protected static int CHANGED(Code)
An int used by updateCurrentCursor() indicating that the user operation has changed.



DEFAULT
final protected static int DEFAULT(Code)
An int used by updateCurrentCursor() indicating that the Cursor should change to the default (no drop) Cursor.



ENTER
final protected static int ENTER(Code)
An int used by updateCurrentCursor() indicating that the Cursor has entered a DropTarget.



OVER
final protected static int OVER(Code)
An int used by updateCurrentCursor() indicating that the Cursor is over a DropTarget.




Constructor Detail
DragSourceContext
public DragSourceContext(DragSourceContextPeer dscp, DragGestureEvent trigger, Cursor dragCursor, Image dragImage, Point offset, Transferable t, DragSourceListener dsl)(Code)
Called from DragSource, this constructor creates a new DragSourceContext given the DragSourceContextPeer for this Drag, the DragGestureEvent that triggered the Drag, the initial Cursor to use for the Drag, an (optional) Image to display while the Drag is taking place, the offset of the Image origin from the hotspot at the instant of the triggering event, the Transferable subject data, and the DragSourceListener to use during the Drag and Drop operation.
If DragSourceContextPeer is null NullPointerException is thrown.
If DragGestureEvent is null NullPointerException is thrown.
If Cursor is null no exception is thrown and the default drag cursor behavior is activated for this drag operation.
If Image is null no exception is thrown.
If Image is not null and the offset is null NullPointerException is thrown.
If Transferable is null NullPointerException is thrown.
If DragSourceListener is null no exception is thrown.
Parameters:
  dscp - the DragSourceContextPeer for this drag
Parameters:
  trigger - the triggering event
Parameters:
  dragCursor - the initial Cursor for this drag operationor null for the default cursor handling;see class level documentationfor more details on the cursor handling mechanism during drag and drop
Parameters:
  dragImage - the Image to drag (or null)
Parameters:
  offset - the offset of the image origin from the hotspot at theinstant of the triggering event
Parameters:
  t - the Transferable
Parameters:
  dsl - the DragSourceListener
throws:
  IllegalArgumentException - if the Component associatedwith the trigger event is null.
throws:
  IllegalArgumentException - if the DragSource for the trigger event is null.
throws:
  IllegalArgumentException - if the drag action for thetrigger event is DnDConstants.ACTION_NONE.
throws:
  IllegalArgumentException - if the source actions for theDragGestureRecognizer associated with the triggerevent are equal to DnDConstants.ACTION_NONE.
throws:
  NullPointerException - if dscp, trigger, or t are null, orif dragImage is non-null and offset is null




Method Detail
addDragSourceListener
public synchronized void addDragSourceListener(DragSourceListener dsl) throws TooManyListenersException(Code)
Add a DragSourceListener to this DragSourceContext if one has not already been added. If a DragSourceListener already exists, this method throws a TooManyListenersException.


Parameters:
  dsl - the DragSourceListener to add.Note that while null is not prohibited,it is not acceptable as a parameter.


throws:
  TooManyListenersException - ifa DragSourceListener has already been added




dragDropEnd
public void dragDropEnd(DragSourceDropEvent dsde)(Code)
Calls dragDropEnd on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDropEvent.
Parameters:
  dsde - the DragSourceDropEvent



dragEnter
public void dragEnter(DragSourceDragEvent dsde)(Code)
Calls dragEnter on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDragEvent.
Parameters:
  dsde - the DragSourceDragEvent



dragExit
public void dragExit(DragSourceEvent dse)(Code)
Calls dragExit on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceEvent.
Parameters:
  dse - the DragSourceEvent



dragMouseMoved
public void dragMouseMoved(DragSourceDragEvent dsde)(Code)
Calls dragMouseMoved on the DragSourceMotionListeners registered with the DragSource associated with this DragSourceContext, and them passes the specified DragSourceDragEvent.
Parameters:
  dsde - the DragSourceDragEvent
since:
   1.4



dragOver
public void dragOver(DragSourceDragEvent dsde)(Code)
Calls dragOver on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDragEvent.
Parameters:
  dsde - the DragSourceDragEvent



dropActionChanged
public void dropActionChanged(DragSourceDragEvent dsde)(Code)
Calls dropActionChanged on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDragEvent.
Parameters:
  dsde - the DragSourceDragEvent



getComponent
public Component getComponent()(Code)
Returns the Component associated with this DragSourceContext. the Component that started the drag



getCursor
public Cursor getCursor()(Code)
Returns the current drag Cursor.

the current drag Cursor




getDragSource
public DragSource getDragSource()(Code)
Returns the DragSource that instantiated this DragSourceContext. the DragSource that instantiated this DragSourceContext



getSourceActions
public int getSourceActions()(Code)
Returns a bitwise mask of DnDConstants that represent the set of drop actions supported by the drag source for the drag operation associated with this DragSourceContext. the drop actions supported by the drag source



getTransferable
public Transferable getTransferable()(Code)
Returns the Transferable associated with this DragSourceContext. the Transferable



getTrigger
public DragGestureEvent getTrigger()(Code)
Returns the DragGestureEvent that initially triggered the drag. the Event that triggered the drag



removeDragSourceListener
public synchronized void removeDragSourceListener(DragSourceListener dsl)(Code)
Removes the specified DragSourceListener from this DragSourceContext.
Parameters:
  dsl - the DragSourceListener to remove;note that while null is not prohibited,it is not acceptable as a parameter



setCursor
public synchronized void setCursor(Cursor c)(Code)
Sets the cursor for this drag operation to the specified Cursor. If the specified Cursor is null, the default drag cursor behavior is activated for this drag operation, otherwise it is deactivated.
Parameters:
  c - the initial Cursor for this drag operation,or null for the default cursor handling;see for more detailson the cursor handling during drag and drop



transferablesFlavorsChanged
public void transferablesFlavorsChanged()(Code)
Notifies the peer that the Transferable's DataFlavors have changed.



updateCurrentCursor
protected synchronized void updateCurrentCursor(int sourceAct, int targetAct, int status)(Code)
If the default drag cursor behavior is active, this method sets the default drag cursor for the specified actions supported by the drag source, the drop target action, and status, otherwise this method does nothing.
Parameters:
  sourceAct - the actions supported by the drag source
Parameters:
  targetAct - the drop target action
Parameters:
  status - one of the fields DEFAULT,ENTER, OVER, CHANGED



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.