Class DataFormat
- javafx.scene.input.DataFormat
public class DataFormat extends Object
Since:
JavaFX 2.0
-
Field Summary
Fields Modifier and Type Field and Description static DataFormatFILESRepresents a List of Files.static DataFormatHTMLRepresents an HTML formatted string.static DataFormatIMAGEA special platform specific image type, such as is commonly used on the clipboard and interoperates widely with other applications.static DataFormatPLAIN_TEXTRepresents a plain text string.static DataFormatRTFRepresents an RTF formatted stringstatic DataFormatURLRepresents a URL, encoded as a String
-
Constructor Summary
Constructors Constructor and Description DataFormat(String... ids)Create a new DataFormat, specifying the set of ids that are associated with this data format.
-
Method Summary
All MethodsStatic MethodsInstance MethodsConcrete Methods Modifier and Type Method and Description booleanequals(Object obj)Indicates whether some other object is "equal to" this one.Set<String>getIdentifiers()Gets the unmodifiable set of identifiers for this DataFormat.inthashCode()Returns a hash code for thisDataFormatobject.static DataFormatlookupMimeType(String mimeType)Looks for the DataFormat which has been previously created with the given mime type as one of its ids.StringtoString()Returns a string representation of thisDataFormatobject.
-
Field Detail
-
PLAIN_TEXT
public static final DataFormat PLAIN_TEXT
Represents a plain text string.
-
HTML
public static final DataFormat HTML
Represents an HTML formatted string.
-
RTF
public static final DataFormat RTF
Represents an RTF formatted string
-
URL
public static final DataFormat URL
Represents a URL, encoded as a String
-
IMAGE
public static final DataFormat IMAGE
A special platform specific image type, such as is commonly used on the clipboard and interoperates widely with other applications. For example, on Mac this might ultimately be a TIFF while on Windows it might be a DIB (device independent bitmap).
-
FILES
public static final DataFormat FILES
Represents a List of Files.
-
-
Constructor Detail
-
DataFormat
public DataFormat(String... ids)
Create a new DataFormat, specifying the set of ids that are associated with this data format. Typically the ids are one or more mime types. For each id, any data associated with this DataFormat will be registered on the clipboard. For example, suppose I had the following: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
idis not of the "type/subtype" format it won't be possible to drag data of this type from/toJFXPanel.Parameters:
ids- The set of ids used to represent this DataFormat on the clipboard.Throws:
IllegalArgumentException- if one of the given mime types is already assigned to another DataFormat.
-
-
Method Detail
-
getIdentifiers
public final Set<String> getIdentifiers()
Gets the unmodifiable set of identifiers for this DataFormat.Returns:
an unmodifiable set that is never null.
-
toString
public String toString()
Returns a string representation of thisDataFormatobject.
-
hashCode
public int hashCode()
Returns a hash code for thisDataFormatobject.
-
equals
public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one.
-
lookupMimeType
public static DataFormat lookupMimeType(String mimeType)
Looks for the DataFormat which has been previously created with the given mime type as one of its ids.Parameters:
mimeType- If null or the empty string, then null is returned.Returns:
The matching DataFormat
-
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.