public class DataFormat extends Object
Modifier and Type | Field and Description |
---|---|
static DataFormat |
FILES
Represents a List of Files.
|
static DataFormat |
HTML
Represents an HTML formatted string.
|
static DataFormat |
IMAGE
A special platform specific image type, such as is commonly used
on the clipboard and interoperates widely with other applications.
|
static DataFormat |
PLAIN_TEXT
Represents a plain text string.
|
static DataFormat |
RTF
Represents an RTF formatted string
|
static DataFormat |
URL
Represents a URL, encoded as a String
|
Constructor and Description |
---|
DataFormat(String... ids)
Create a new DataFormat, specifying the set of ids that are associated with
this data format.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
Set<String> |
getIdentifiers()
Gets the unmodifiable set of identifiers for this DataFormat.
|
int |
hashCode()
Returns a hash code for this
DataFormat object. |
static DataFormat |
lookupMimeType(String mimeType)
Looks for the DataFormat which has been previously created with
the given mime type as one of its ids.
|
String |
toString()
Returns a string representation of this
DataFormat object. |
public static final DataFormat PLAIN_TEXT
public static final DataFormat HTML
public static final DataFormat RTF
public static final DataFormat URL
public static final DataFormat IMAGE
public static final DataFormat FILES
public DataFormat(String... ids)
DataFormat fmt = new DataFormat("text/foo", "text/bar");
Clipboard clipboard = Clipboard.getSystemClipboard();
ClipboardContent content = new ClipboardContent();
content.put(fmt, "Hello");
clipboard.setContent(content);
With the above code, if I were to look on the clipboard, I'd find the String "Hello"
listed both for "text/foo" and "text/bar" on the clipboard.
Note that the ids may be subject to platform restrictions in some cases.
For instance, Swing requires a mime type so if an id
is not
of the "type/subtype" format it won't be possible
to drag data of this type from/to JFXPanel
.
ids
- The set of ids used to represent this DataFormat on the clipboard.IllegalArgumentException
- if one of the given mime types is already
assigned to another DataFormat.public final Set<String> getIdentifiers()
public String toString()
DataFormat
object.public int hashCode()
DataFormat
object.public boolean equals(Object obj)
public static DataFormat lookupMimeType(String mimeType)
mimeType
- If null or the empty string, then null is returned.Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2020, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.