net.sf.freecol.client.gui.panel
Class DefaultTransferHandler

java.lang.Object
  extended by javax.swing.TransferHandler
      extended by net.sf.freecol.client.gui.panel.DefaultTransferHandler
All Implemented Interfaces:
java.io.Serializable

public final class DefaultTransferHandler
extends javax.swing.TransferHandler

The transferhandler that is capable of creating ImageSelection objects. Those ImageSelection objects are Transferable. The DefaultTransferHandler should be attached to JPanels or custom JLabels.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.TransferHandler
javax.swing.TransferHandler.DropLocation, javax.swing.TransferHandler.TransferSupport
 
Field Summary
static java.awt.datatransfer.DataFlavor flavor
           
 
Fields inherited from class javax.swing.TransferHandler
COPY, COPY_OR_MOVE, LINK, MOVE, NONE
 
Constructor Summary
DefaultTransferHandler(Canvas canvas, FreeColPanel parentPanel)
          The constructor to use.
 
Method Summary
 boolean canImport(javax.swing.JComponent comp, java.awt.datatransfer.DataFlavor[] flavor)
          Returns 'true' if the given component can import a selection of the flavor that is indicated by the second parameter, 'false' otherwise.
 java.awt.datatransfer.Transferable createTransferable(javax.swing.JComponent comp)
          Creates a Transferable (an ImageSelection to be precise) of the data that is represented by the given component and returns that object.
 void exportAsDrag(javax.swing.JComponent comp, java.awt.event.InputEvent e, int action)
           
 int getSourceActions(javax.swing.JComponent comp)
          Returns the action that can be done to an ImageSelection on the given component.
 boolean importData(javax.swing.JComponent comp, java.awt.datatransfer.Transferable t)
          Imports the data represented by the given Transferable into the given component.
 
Methods inherited from class javax.swing.TransferHandler
canImport, exportToClipboard, getCopyAction, getCutAction, getPasteAction, getVisualRepresentation, importData
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flavor

public static final java.awt.datatransfer.DataFlavor flavor
Constructor Detail

DefaultTransferHandler

public DefaultTransferHandler(Canvas canvas,
                              FreeColPanel parentPanel)
The constructor to use.

Parameters:
canvas - The Canvas.
parentPanel - The layered pane that holds all kinds of information.
Method Detail

getSourceActions

public int getSourceActions(javax.swing.JComponent comp)
Returns the action that can be done to an ImageSelection on the given component.

Overrides:
getSourceActions in class javax.swing.TransferHandler
Returns:
The action that can be done to an ImageSelection on the given component.

canImport

public boolean canImport(javax.swing.JComponent comp,
                         java.awt.datatransfer.DataFlavor[] flavor)
Returns 'true' if the given component can import a selection of the flavor that is indicated by the second parameter, 'false' otherwise.

Overrides:
canImport in class javax.swing.TransferHandler
Parameters:
comp - The component that needs to be checked.
flavor - The flavor that needs to be checked for.
Returns:
'true' if the given component can import a selection of the flavor that is indicated by the second parameter, 'false' otherwise.

createTransferable

public java.awt.datatransfer.Transferable createTransferable(javax.swing.JComponent comp)
Creates a Transferable (an ImageSelection to be precise) of the data that is represented by the given component and returns that object.

Overrides:
createTransferable in class javax.swing.TransferHandler
Parameters:
comp - The component to create a Transferable of.
Returns:
The resulting Transferable (an ImageSelection object).

importData

public boolean importData(javax.swing.JComponent comp,
                          java.awt.datatransfer.Transferable t)
Imports the data represented by the given Transferable into the given component. Returns 'true' on success, 'false' otherwise.

Overrides:
importData in class javax.swing.TransferHandler
Parameters:
comp - The component to import the data to.
t - The Transferable that holds the data.
Returns:
'true' on success, 'false' otherwise.

exportAsDrag

public void exportAsDrag(javax.swing.JComponent comp,
                         java.awt.event.InputEvent e,
                         int action)
Overrides:
exportAsDrag in class javax.swing.TransferHandler