Top Description Inners Constructors Methods
com.sun.jna.examples.dnd

public Class GhostedDragImageDemo

extends Object
Class Inheritance
Imports
java.awt.Image, .Point, java.awt.datatransfer.Clipboard, .ClipboardOwner, .DataFlavor, .Transferable, .UnsupportedFlavorException, java.awt.dnd.DnDConstants, .DragGestureEvent, .DragSourceDropEvent, .DropTargetDropEvent, java.io.IOException, java.net.URL, javax.swing.Icon, .ImageIcon, .JFrame, .JLabel, .UIManager

Demonstrate ghosted drag images. Unfortunately, Swing drag support hides the hooks we need to move the drag image around, so we don't use it and roll our own.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
main(String[] args)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

GhostedDragImageDemoback to summary
public GhostedDragImageDemo()

Method Detail

mainback to summary
public static void main(String[] args)
com.sun.jna.examples.dnd back to summary

public Class GhostedDragImageDemo.DragLabel

extends JLabel
Class Inheritance

Field Summary

Modifier and TypeField and Description
private boolean
Inherited from javax.swing.JLabel:
labelFor

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
setIcon(Icon
the default icon this component will display
icon
)

Overrides javax.swing.JLabel.setIcon.

Defines the icon this component will display.
Inherited from javax.swing.JLabel:
checkHorizontalKeycheckVerticalKeygetAccessibleContextgetDisabledIcongetDisplayedMnemonicgetDisplayedMnemonicIndexgetHorizontalAlignmentgetHorizontalTextPositiongetIcongetIconTextGapgetLabelForgetTextgetUIgetUIClassIDgetVerticalAlignmentgetVerticalTextPositionimageUpdateparamStringsetDisabledIconsetDisplayedMnemonicsetDisplayedMnemonicsetDisplayedMnemonicIndexsetHorizontalAlignmentsetHorizontalTextPositionsetIconTextGapsetLabelForsetTextsetUIsetVerticalAlignmentsetVerticalTextPositionupdateUI

Field Detail

draggingback to summary
private boolean dragging

Constructor Detail

DragLabelback to summary
public DragLabel(Icon icon)

Method Detail

setIconback to summary
public void setIcon(Icon icon)

Overrides javax.swing.JLabel.setIcon.

Doc from javax.swing.JLabel.setIcon.

Defines the icon this component will display. If the value of icon is null, nothing is displayed.

The default value of this property is null.

This is a JavaBeans bound property.

Parameters
icon:Icon

the default icon this component will display

com.sun.jna.examples.dnd back to summary

public Class GhostedDragImageDemo.ImageSelection

extends Object
implements Transferable, ClipboardOwner
Class Inheritance
All Implemented Interfaces
java.awt.datatransfer.ClipboardOwner, java.awt.datatransfer.Transferable

Field Summary

Modifier and TypeField and Description
private static final DataFlavor[]
private Image
public static final DataFlavor

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object
getTransferData(DataFlavor
the requested flavor for the data
flavor
)

Implements java.awt.datatransfer.Transferable.getTransferData.

Returns an object which represents the data to be transferred.
public DataFlavor[]
getTransferDataFlavors()

Implements java.awt.datatransfer.Transferable.getTransferDataFlavors.

Returns an array of DataFlavor objects indicating the flavors the data can be provided in. The array should be ordered according to preference for providing the data (from most richly descriptive to least descriptive).
public boolean
isDataFlavorSupported(DataFlavor
the requested flavor for the data
flavor
)

Implements java.awt.datatransfer.Transferable.isDataFlavorSupported.

Returns whether or not the specified data flavor is supported for this object.
public void
lostOwnership(Clipboard
the clipboard that is no longer owned
clipboard
,
Transferable
the contents which this owner had placed on the clipboard
transferable
)

Implements java.awt.datatransfer.ClipboardOwner.lostOwnership.

Notifies this object that it is no longer the clipboard owner.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FLAVORSback to summary
private static final DataFlavor[] FLAVORS
imageback to summary
private Image image
IMAGE_FLAVORback to summary
public static final DataFlavor IMAGE_FLAVOR

Constructor Detail

ImageSelectionback to summary
public ImageSelection(Image image)

Method Detail

getTransferDataback to summary
public Object getTransferData(DataFlavor flavor)

Implements java.awt.datatransfer.Transferable.getTransferData.

Doc from java.awt.datatransfer.Transferable.getTransferData.

Returns an object which represents the data to be transferred. The class of the object returned is defined by the representation class of the flavor.

Parameters
flavor:DataFlavor

the requested flavor for the data

Returns:Object

an object which represents the data to be transferred

getTransferDataFlavorsback to summary
public DataFlavor[] getTransferDataFlavors()

Implements java.awt.datatransfer.Transferable.getTransferDataFlavors.

Doc from java.awt.datatransfer.Transferable.getTransferDataFlavors.

Returns an array of DataFlavor objects indicating the flavors the data can be provided in. The array should be ordered according to preference for providing the data (from most richly descriptive to least descriptive).

Returns:DataFlavor[]

an array of data flavors in which this data can be transferred

isDataFlavorSupportedback to summary
public boolean isDataFlavorSupported(DataFlavor flavor)

Implements java.awt.datatransfer.Transferable.isDataFlavorSupported.

Doc from java.awt.datatransfer.Transferable.isDataFlavorSupported.

Returns whether or not the specified data flavor is supported for this object.

Parameters
flavor:DataFlavor

the requested flavor for the data

Returns:boolean

boolean indicating whether or not the data flavor is supported

lostOwnershipback to summary
public void lostOwnership(Clipboard clipboard, Transferable transferable)

Implements java.awt.datatransfer.ClipboardOwner.lostOwnership.

Doc from java.awt.datatransfer.ClipboardOwner.lostOwnership.

Notifies this object that it is no longer the clipboard owner. This method will be called when another application or another object within this application asserts ownership of the clipboard.

Parameters
clipboard:Clipboard

the clipboard that is no longer owned

transferable:Transferable

the contents which this owner had placed on the clipboard