本文整理汇总了Java中java.awt.datatransfer.FlavorMap类的典型用法代码示例。如果您正苦于以下问题:Java FlavorMap类的具体用法?Java FlavorMap怎么用?Java FlavorMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FlavorMap类属于java.awt.datatransfer包,在下文中一共展示了FlavorMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DropTarget
import java.awt.datatransfer.FlavorMap; //导入依赖的package包/类
/**
* Creates a <code>DropTarget</code> object.
*
* @exception HeadlessException If GraphicsEnvironment.isHeadless()
* returns true.
*/
public DropTarget (Component c, int i, DropTargetListener dtl, boolean b,
FlavorMap fm)
{
if (GraphicsEnvironment.isHeadless ())
throw new HeadlessException ();
setComponent(c);
setDefaultActions(i);
dropTargetListener = dtl;
if (fm == null)
flavorMap = SystemFlavorMap.getDefaultFlavorMap();
else
flavorMap = fm;
setActive (b);
if (c != null)
c.setDropTarget(this);
}
示例2: createDataFlavor
import java.awt.datatransfer.FlavorMap; //导入依赖的package包/类
public static DataFlavor createDataFlavor(@NotNull final String mimeType, @Nullable final Class<?> klass, final boolean register) {
try {
final DataFlavor flavor =
klass != null ? new DataFlavor(mimeType + ";class=" + klass.getName(), null, klass.getClassLoader()) : new DataFlavor(mimeType);
if (register) {
final FlavorMap map = SystemFlavorMap.getDefaultFlavorMap();
if (map instanceof SystemFlavorMap) {
((SystemFlavorMap)map).addUnencodedNativeForFlavor(flavor, mimeType);
}
}
return flavor;
}
catch (ClassNotFoundException e) {
LOG.error(e);
//noinspection ConstantConditions
return null;
}
}
示例3: DropTarget
import java.awt.datatransfer.FlavorMap; //导入依赖的package包/类
/**
* Creates a <code>DropTarget</code> object.
*
* @exception HeadlessException If GraphicsEnvironment.isHeadless()
* returns true.
*/
public DropTarget (Component c, int i, DropTargetListener dtl, boolean b,
FlavorMap fm)
{
if (GraphicsEnvironment.isHeadless ())
throw new HeadlessException ();
setComponent(c);
setDefaultActions(i);
dropTargetListener = dtl;
if (fm == null)
flavorMap = SystemFlavorMap.getDefaultFlavorMap();
else
flavorMap = fm;
setActive (b);
if (c != null)
c.setDropTarget(this);
}
示例4: DropTarget
import java.awt.datatransfer.FlavorMap; //导入依赖的package包/类
/**
* Creates a new DropTarget given the <code>Component</code>
* to associate itself with, an <code>int</code> representing
* the default acceptable action(s) to
* support, a <code>DropTargetListener</code>
* to handle event processing, a <code>boolean</code> indicating
* if the <code>DropTarget</code> is currently accepting drops, and
* a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>).
* <P>
* The Component will receive drops only if it is enabled.
* @param c The <code>Component</code> with which this <code>DropTarget</code> is associated
* @param ops The default acceptable actions for this <code>DropTarget</code>
* @param dtl The <code>DropTargetListener</code> for this <code>DropTarget</code>
* @param act Is the <code>DropTarget</code> accepting drops.
* @param fm The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE>
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see java.awt.GraphicsEnvironment#isHeadless
*/
public DropTarget(Component c, int ops, DropTargetListener dtl,
boolean act, FlavorMap fm)
throws HeadlessException
{
if (GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
}
component = c;
setDefaultActions(ops);
if (dtl != null) try {
addDropTargetListener(dtl);
} catch (TooManyListenersException tmle) {
// do nothing!
}
if (c != null) {
c.setDropTarget(this);
setActive(act);
}
if (fm != null) flavorMap = fm;
}
示例5: SwingClipboard
import java.awt.datatransfer.FlavorMap; //导入依赖的package包/类
public SwingClipboard() {
super(SwingOptions.getClipbaordPollingMillis());
if (!SwingUtilities.isEventDispatchThread()) {
throw new IllegalStateException("The clipboard must be created in the event dispatcher thread");
}
this.systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
final FlavorMap map = SystemFlavorMap.getDefaultFlavorMap();
if (map instanceof SystemFlavorMap) {
final SystemFlavorMap systemMap = (SystemFlavorMap) map;
systemMap.addFlavorForUnencodedNative(TransferContainer.MIME_TYPE, TRANSFER_CONTAINER_FLAVOR);
systemMap.addUnencodedNativeForFlavor(TRANSFER_CONTAINER_FLAVOR, TransferContainer.MIME_TYPE);
}
checkContentChanged();
}
示例6: startDrag
import java.awt.datatransfer.FlavorMap; //导入依赖的package包/类
public void startDrag(DragGestureEvent trigger, Cursor dragCursor,
Image dragImage, Point imageOffset,
Transferable transferable, DragSourceListener dsl,
FlavorMap flavorMap)
throws InvalidDnDOperationException {
if (curContext != null) {
// awt.171=Attempt to start a drag while an existing drag operation is still executing.
throw new InvalidDnDOperationException(Messages.getString("awt.171")); //$NON-NLS-1$
}
DragSourceContextPeer peer =
Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);
curContext = createDragSourceContext(peer, trigger, dragCursor,
dragImage, imageOffset,
transferable, dsl);
peer.startDrag(curContext, dragCursor, dragImage, imageOffset);
curContext = null;
}
示例7: testDropTargetComponentintDropTargetListenerbooleanFlavorMap
import java.awt.datatransfer.FlavorMap; //导入依赖的package包/类
public void testDropTargetComponentintDropTargetListenerbooleanFlavorMap() {
Component c = new Component() {};
int ops = 1;
DropTargetListener dtl = new DTL();
FlavorMap fm = new FM();
DropTarget dt = new DropTarget(c, ops, dtl, false, fm);
assertSame(c, dt.getComponent());
assertSame(dt, c.getDropTarget());
assertEquals(ops, dt.getDefaultActions());
assertFalse(dt.isActive());
assertSame(fm, dt.getFlavorMap());
try {
dt.removeDropTargetListener(new DTL());
fail("IllegalArgumentException expected");
} catch (IllegalArgumentException e) {
}
dt.removeDropTargetListener(dtl);
}
示例8: createDataFlavor
import java.awt.datatransfer.FlavorMap; //导入依赖的package包/类
public static DataFlavor createDataFlavor(@NotNull final String mimeType, @Nullable final Class<?> klass, final boolean register) {
try {
final String typeString = klass != null ? mimeType + ";class=" + klass.getName() : mimeType;
final DataFlavor flavor = new DataFlavor(typeString);
if (register) {
final FlavorMap map = SystemFlavorMap.getDefaultFlavorMap();
if (map instanceof SystemFlavorMap) {
((SystemFlavorMap)map).addUnencodedNativeForFlavor(flavor, mimeType);
}
}
return flavor;
}
catch (ClassNotFoundException e) {
LOG.error(e);
//noinspection ConstantConditions
return null;
}
}
示例9: createDataFlavor
import java.awt.datatransfer.FlavorMap; //导入依赖的package包/类
public static DataFlavor createDataFlavor(@Nonnull final String mimeType, @Nullable final Class<?> klass, final boolean register) {
try {
final DataFlavor flavor =
klass != null ? new DataFlavor(mimeType + ";class=" + klass.getName(), null, klass.getClassLoader()) : new DataFlavor(mimeType);
if (register) {
final FlavorMap map = SystemFlavorMap.getDefaultFlavorMap();
if (map instanceof SystemFlavorMap) {
((SystemFlavorMap)map).addUnencodedNativeForFlavor(flavor, mimeType);
}
}
return flavor;
}
catch (ClassNotFoundException e) {
LOG.error(e);
//noinspection ConstantConditions
return null;
}
}
示例10: DropTarget
import java.awt.datatransfer.FlavorMap; //导入依赖的package包/类
/**
* Creates a new DropTarget given the <code>Component</code>
* to associate itself with, an <code>int</code> representing
* the default acceptable action(s) to
* support, a <code>DropTargetListener</code>
* to handle event processing, a <code>boolean</code> indicating
* if the <code>DropTarget</code> is currently accepting drops, and
* a <code>FlavorMap</code> to use (or null for the default <CODE>FlavorMap</CODE>).
* <P>
* The Component will receive drops only if it is enabled.
* @param c The <code>Component</code> with which this <code>DropTarget</code> is associated
* @param ops The default acceptable actions for this <code>DropTarget</code>
* @param dtl The <code>DropTargetListener</code> for this <code>DropTarget</code>
* @param act Is the <code>DropTarget</code> accepting drops.
* @param fm The <code>FlavorMap</code> to use, or null for the default <CODE>FlavorMap</CODE>
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see java.awt.GraphicsEnvironment#isHeadless
*/
public DropTarget(Component c, int ops, DropTargetListener dtl,
boolean act, FlavorMap fm)
throws HeadlessException
{
if (GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
}
component = c;
setDefaultActions(ops);
if (dtl != null) try {
addDropTargetListener(dtl);
} catch (TooManyListenersException tmle) {
// do nothing!
}
if (c != null) {
c.setDropTarget(this);
setActive(act);
}
if (fm != null) {
flavorMap = fm;
} else {
flavorMap = SystemFlavorMap.getDefaultFlavorMap();
}
}
示例11: startDrag
import java.awt.datatransfer.FlavorMap; //导入依赖的package包/类
/**
* Start a drag, given the <code>DragGestureEvent</code>
* that initiated the drag, the initial
* <code>Cursor</code> to use,
* the <code>Image</code> to drag,
* the offset of the <code>Image</code> origin
* from the hotspot of the <code>Cursor</code> at
* the instant of the trigger,
* the <code>Transferable</code> subject data
* of the drag, the <code>DragSourceListener</code>,
* and the <code>FlavorMap</code>.
* <P>
* @param trigger the <code>DragGestureEvent</code> that initiated the drag
* @param dragCursor the initial {@code Cursor} for this drag operation
* or {@code null} for the default cursor handling;
* see <a href="DragSourceContext.html#defaultCursor">DragSourceContext</a>
* for more details on the cursor handling mechanism during drag and drop
* @param dragImage the image to drag or {@code null}
* @param imageOffset the offset of the <code>Image</code> origin from the hotspot
* of the <code>Cursor</code> at the instant of the trigger
* @param transferable the subject data of the drag
* @param dsl the <code>DragSourceListener</code>
* @param flavorMap the <code>FlavorMap</code> to use, or <code>null</code>
* <P>
* @throws java.awt.dnd.InvalidDnDOperationException
* if the Drag and Drop
* system is unable to initiate a drag operation, or if the user
* attempts to start a drag while an existing drag operation
* is still executing
*/
public void startDrag(DragGestureEvent trigger,
Cursor dragCursor,
Image dragImage,
Point imageOffset,
Transferable transferable,
DragSourceListener dsl,
FlavorMap flavorMap) throws InvalidDnDOperationException {
SunDragSourceContextPeer.setDragDropInProgress(true);
try {
if (flavorMap != null) this.flavorMap = flavorMap;
DragSourceContextPeer dscp = Toolkit.getDefaultToolkit().createDragSourceContextPeer(trigger);
DragSourceContext dsc = createDragSourceContext(dscp,
trigger,
dragCursor,
dragImage,
imageOffset,
transferable,
dsl
);
if (dsc == null) {
throw new InvalidDnDOperationException();
}
dscp.startDrag(dsc, dsc.getCursor(), dragImage, imageOffset); // may throw
} catch (RuntimeException e) {
SunDragSourceContextPeer.setDragDropInProgress(false);
throw e;
}
}
示例12: readObject
import java.awt.datatransfer.FlavorMap; //导入依赖的package包/类
/**
* Deserializes this <code>DragSource</code>. This method first performs
* default deserialization. Next, this object's <code>FlavorMap</code> is
* deserialized by using the next object in the stream.
* If the resulting <code>FlavorMap</code> is <code>null</code>, this
* object's <code>FlavorMap</code> is set to the default FlavorMap for
* this thread's <code>ClassLoader</code>.
* Next, this object's listeners are deserialized by reading a
* <code>null</code>-terminated sequence of 0 or more key/value pairs
* from the stream:
* <ul>
* <li>If a key object is a <code>String</code> equal to
* <code>dragSourceListenerK</code>, a <code>DragSourceListener</code> is
* deserialized using the corresponding value object and added to this
* <code>DragSource</code>.
* <li>If a key object is a <code>String</code> equal to
* <code>dragSourceMotionListenerK</code>, a
* <code>DragSourceMotionListener</code> is deserialized using the
* corresponding value object and added to this <code>DragSource</code>.
* <li>Otherwise, the key/value pair is skipped.
* </ul>
*
* @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
* @since 1.4
*/
private void readObject(ObjectInputStream s)
throws ClassNotFoundException, IOException {
s.defaultReadObject();
// 'flavorMap' was written explicitly
flavorMap = (FlavorMap)s.readObject();
// Implementation assumes 'flavorMap' is never null.
if (flavorMap == null) {
flavorMap = SystemFlavorMap.getDefaultFlavorMap();
}
Object keyOrNull;
while (null != (keyOrNull = s.readObject())) {
String key = ((String)keyOrNull).intern();
if (dragSourceListenerK == key) {
addDragSourceListener((DragSourceListener)(s.readObject()));
} else if (dragSourceMotionListenerK == key) {
addDragSourceMotionListener(
(DragSourceMotionListener)(s.readObject()));
} else {
// skip value for unrecognized key
s.readObject();
}
}
}
示例13: DropTarget
import java.awt.datatransfer.FlavorMap; //导入依赖的package包/类
/**
* Creates a new DropTarget given the {@code Component}
* to associate itself with, an {@code int} representing
* the default acceptable action(s) to
* support, a {@code DropTargetListener}
* to handle event processing, a {@code boolean} indicating
* if the {@code DropTarget} is currently accepting drops, and
* a {@code FlavorMap} to use (or null for the default {@code FlavorMap}).
* <P>
* The Component will receive drops only if it is enabled.
* @param c The {@code Component} with which this {@code DropTarget} is associated
* @param ops The default acceptable actions for this {@code DropTarget}
* @param dtl The {@code DropTargetListener} for this {@code DropTarget}
* @param act Is the {@code DropTarget} accepting drops.
* @param fm The {@code FlavorMap} to use, or null for the default {@code FlavorMap}
* @exception HeadlessException if GraphicsEnvironment.isHeadless()
* returns true
* @see java.awt.GraphicsEnvironment#isHeadless
*/
public DropTarget(Component c, int ops, DropTargetListener dtl,
boolean act, FlavorMap fm)
throws HeadlessException
{
if (GraphicsEnvironment.isHeadless()) {
throw new HeadlessException();
}
component = c;
setDefaultActions(ops);
if (dtl != null) try {
addDropTargetListener(dtl);
} catch (TooManyListenersException tmle) {
// do nothing!
}
if (c != null) {
c.setDropTarget(this);
setActive(act);
}
if (fm != null) {
flavorMap = fm;
} else {
flavorMap = SystemFlavorMap.getDefaultFlavorMap();
}
}
示例14: readObject
import java.awt.datatransfer.FlavorMap; //导入依赖的package包/类
/**
* Deserializes this {@code DragSource}. This method first performs
* default deserialization. Next, this object's {@code FlavorMap} is
* deserialized by using the next object in the stream.
* If the resulting {@code FlavorMap} is {@code null}, this
* object's {@code FlavorMap} is set to the default FlavorMap for
* this thread's {@code ClassLoader}.
* Next, this object's listeners are deserialized by reading a
* {@code null}-terminated sequence of 0 or more key/value pairs
* from the stream:
* <ul>
* <li>If a key object is a {@code String} equal to
* {@code dragSourceListenerK}, a {@code DragSourceListener} is
* deserialized using the corresponding value object and added to this
* {@code DragSource}.
* <li>If a key object is a {@code String} equal to
* {@code dragSourceMotionListenerK}, a
* {@code DragSourceMotionListener} is deserialized using the
* corresponding value object and added to this {@code DragSource}.
* <li>Otherwise, the key/value pair is skipped.
* </ul>
*
* @see java.awt.datatransfer.SystemFlavorMap#getDefaultFlavorMap
* @since 1.4
*/
private void readObject(ObjectInputStream s)
throws ClassNotFoundException, IOException {
s.defaultReadObject();
// 'flavorMap' was written explicitly
flavorMap = (FlavorMap)s.readObject();
// Implementation assumes 'flavorMap' is never null.
if (flavorMap == null) {
flavorMap = SystemFlavorMap.getDefaultFlavorMap();
}
Object keyOrNull;
while (null != (keyOrNull = s.readObject())) {
String key = ((String)keyOrNull).intern();
if (dragSourceListenerK == key) {
addDragSourceListener((DragSourceListener)(s.readObject()));
} else if (dragSourceMotionListenerK == key) {
addDragSourceMotionListener(
(DragSourceMotionListener)(s.readObject()));
} else {
// skip value for unrecognized key
s.readObject();
}
}
}
示例15: getFlavorMap
import java.awt.datatransfer.FlavorMap; //导入依赖的package包/类
@Override
public FlavorMap getFlavorMap(Supplier<FlavorMap> supplier) {
AppContext context = AppContext.getAppContext();
FlavorMap fm = (FlavorMap) context.get(FLAVOR_MAP_KEY);
if (fm == null) {
fm = supplier.get();
context.put(FLAVOR_MAP_KEY, fm);
}
return fm;
}