API java : DragSourceContext


java.awt.dnd
Class DragSourceContext

java.lang.Object
  extended by java.awt.dnd.DragSourceContext
All Implemented Interfaces:
DragSourceListener, DragSourceMotionListener, Serializable, EventListener

public class DragSourceContext
extends Object
implements DragSourceListener, DragSourceMotionListener, Serializable

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 DragSourceListeners and DragSourceMotionListeners, 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 to interpose itself between the platform and the listeners provided by the initiator of the drag operation.

Since:
1.2
See Also:
DragSourceListener, DragSourceMotionListener, Serialized Form

Field Summary
protected static int CHANGED
          An int used by updateCurrentCursor() indicating that the user operation has changed.
protected static int DEFAULT
          An int used by updateCurrentCursor() indicating that the Cursor should change to the default (no drop) Cursor.
protected static int ENTER
          An int used by updateCurrentCursor() indicating that the Cursor has entered a DropTarget.
protected static int OVER
          An int used by updateCurrentCursor() indicating that the Cursor is over a DropTarget.
 
Constructor Summary
DragSourceContext(java.awt.dnd.peer.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.
 
Method Summary
 void addDragSourceListener(DragSourceListener dsl)
          Add a DragSourceListener to this DragSourceContext if one has not already been added.
 void dragDropEnd(DragSourceDropEvent dsde)
          Calls dragDropEnd on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDropEvent.
 void dragEnter(DragSourceDragEvent dsde)
          Calls dragEnter on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDragEvent.
 void dragExit(DragSourceEvent dse)
          Calls dragExit on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceEvent.
 void dragMouseMoved(DragSourceDragEvent dsde)
          Calls dragMouseMoved on the DragSourceMotionListeners registered with the DragSource associated with this DragSourceContext, and them passes the specified DragSourceDragEvent.
 void dragOver(DragSourceDragEvent dsde)
          Calls dragOver on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDragEvent.
 void dropActionChanged(DragSourceDragEvent dsde)
          Calls dropActionChanged on the DragSourceListeners registered with this DragSourceContext and with the associated DragSource, and passes them the specified DragSourceDragEvent.
 Component getComponent()
          Returns the Component associated with this DragSourceContext.
 Cursor getCursor()
          Returns the current drag Cursor.
 DragSource getDragSource()
          Returns the DragSource that instantiated this DragSourceContext.
 int getSourceActions()
          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.
 Transferable getTransferable()
          Returns the Transferable associated with this DragSourceContext.
 DragGestureEvent getTrigger()
          Returns the DragGestureEvent that initially triggered the drag.
 void removeDragSourceListener(DragSourceListener dsl)
          Removes the specified DragSourceListener from this DragSourceContext.
 void setCursor(Cursor c)
          Sets the cursor for this drag operation to the specified Cursor.
 void transferablesFlavorsChanged()
          Notifies the peer that the Transferable's DataFlavors have changed.
protected  void updateCurrentCursor(int dropOp, int targetAct, int status)
          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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT

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

See Also:
Constant Field Values

ENTER

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

See Also:
Constant Field Values

OVER

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

See Also:
Constant Field Values

CHANGED

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

See Also:
Constant Field Values
Constructor Detail

DragSourceContext

public DragSourceContext(java.awt.dnd.peer.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
trigger - the triggering event
dragCursor - the initial Cursor
dragImage - the Image to drag (or null)
offset - the offset of the image origin from the hotspot at the instant of the triggering event
t - the Transferable
dsl - the DragSourceListener
Throws:
IllegalArgumentException - if the Component associated with the trigger event is null.
IllegalArgumentException - if the DragSource for the trigger event is null.
IllegalArgumentException - if the drag action for the trigger event is DnDConstants.ACTION_NONE.
IllegalArgumentException - if the source actions for the DragGestureRecognizer associated with the trigger event are equal to DnDConstants.ACTION_NONE.
NullPointerException - if dscp, trigger, or t are null, or if dragImage is non-null and offset is null
Method Detail

getDragSource

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

Returns:
the DragSource that instantiated this DragSourceContext

getComponent

public Component getComponent()
Returns the Component associated with this DragSourceContext.

Returns:
the Component that started the drag

getTrigger

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

Returns:
the Event that triggered the drag

getSourceActions

public int getSourceActions()
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.

Returns:
the drop actions supported by the drag source

setCursor

public void setCursor(Cursor c)
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 Cursor to display, or null to activate the default drag cursor behavior

getCursor

public Cursor getCursor()
Returns the current drag Cursor.

Returns:
the current drag Cursor

addDragSourceListener

public void addDragSourceListener(DragSourceListener dsl)
                           throws TooManyListenersException
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 - if a DragSourceListener has already been added
TooManyListenersException

removeDragSourceListener

public void removeDragSourceListener(DragSourceListener dsl)
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

transferablesFlavorsChanged

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


dragEnter

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

Specified by:
dragEnter in interface DragSourceListener
Parameters:
dsde - the DragSourceDragEvent

dragOver

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

Specified by:
dragOver in interface DragSourceListener
Parameters:
dsde - the DragSourceDragEvent

dragExit

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

Specified by:
dragExit in interface DragSourceListener
Parameters:
dse - the DragSourceEvent

dropActionChanged

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

Specified by:
dropActionChanged in interface DragSourceListener
Parameters:
dsde - the DragSourceDragEvent

dragDropEnd

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

Specified by:
dragDropEnd in interface DragSourceListener
Parameters:
dsde - the DragSourceDropEvent

dragMouseMoved

public void dragMouseMoved(DragSourceDragEvent dsde)
Calls dragMouseMoved on the DragSourceMotionListeners registered with the DragSource associated with this DragSourceContext, and them passes the specified DragSourceDragEvent.

Specified by:
dragMouseMoved in interface DragSourceMotionListener
Parameters:
dsde - the DragSourceDragEvent
Since:
1.4

getTransferable

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

Returns:
the Transferable

updateCurrentCursor

protected void updateCurrentCursor(int dropOp,
                                   int targetAct,
                                   int status)
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.

Parameters:
dropOp - the user's currently selected operation
targetAct - the current target's supported actions
status - the constant

Ces informations proviennent du site de http://java.sun.com

Remarques

Contenu

Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :

Quels sont les motivations de cette démarche?

Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.

Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.

Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.

Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.

Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.

Réseaux sociaux

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.

 

Nuage de mots clés

7 mots clés dont 0 définis manuellement (plus d'information...).

Avertissement

Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.

Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.

 

Astuce pour imprimer les couleurs des cellules de tableaux : http://www.gaudry.be/ast-rf-450.html
Aucun commentaire pour cette page

© Ce document issu de l′infobrol est enregistré sous le certificat Cyber PrInterDeposit Digital Numbertection. Enregistrement IDDN n° 5329-1734
Document créé le 30/08/06 21:17, dernière modification le Vendredi 17 Juin 2011, 12:12
Source du document imprimé : http://www.gaudry.be/java-api-rf-java/awt/dnd/DragSourceContext.html Document affiché 1 fois ce mois de Juin.
St.Gaudry©07.01.02
Outils (masquer)
||
Recherche (afficher)
Recherche :

Utilisateur (masquer)
Apparence (afficher)
Stats (afficher)
15832 documents
452 astuces.
549 niouzes.
3099 definitions.
447 membres.
8115 messages.

Document genere en :
0,48 seconde

Mises à jour :
Mises à jour du site
Citation (masquer)
La folie est de toujours se comporter de la même manière et de s'attendre à un résultat différent.

Albert Einstein
 
l'infobrol
Nous sommes le Vendredi 01 Juin 2012, 12:00, toutes les heures sont au format GMT+1.00 Heure, heure d'été (+1)