public final class ClipboardUtils extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private static class |
ClipboardUtils.DoNothingClipboardOwner |
Modifier and Type | Field and Description |
---|---|
private static java.awt.datatransfer.Clipboard |
clipboard |
Modifier | Constructor and Description |
---|---|
private |
ClipboardUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
clear()
Clears the system clipboard.
|
static boolean |
copy(java.awt.datatransfer.Transferable transferable)
Copies the given transferable to the clipboard.
|
static boolean |
copyString(java.lang.String s)
Copy the given string to the clipboard.
|
static java.awt.datatransfer.Clipboard |
getClipboard()
This method should be used from all of JOSM to access the clipboard.
|
static java.awt.datatransfer.Transferable |
getClipboardContent()
Extracts clipboard content as
Transferable object. |
static java.awt.datatransfer.Transferable |
getClipboardContent(java.awt.datatransfer.Clipboard clipboard)
Extracts clipboard content as
Transferable object. |
static java.lang.String |
getClipboardStringContent()
Gets the clipboard content as string.
|
static java.awt.datatransfer.Clipboard |
getSystemSelection()
Gets the singleton instance of the system selection as a
Clipboard object. |
static java.awt.datatransfer.DataFlavor |
newDataFlavor(java.lang.Class<?> c,
java.lang.String humanPresentableName)
Returns a new
DataFlavor for the given class and human-readable name. |
private static java.awt.datatransfer.Clipboard clipboard
private ClipboardUtils()
public static java.awt.datatransfer.Clipboard getClipboard()
It will default to the system clipboard except for cases where that clipboard is not accessible.
getClipboardContent()
public static java.awt.datatransfer.Clipboard getSystemSelection()
Clipboard
object.
This allows an application to read and modify the current, system-wide selection.Clipboard
, or null
if the native platform does not
support a system selection Clipboard
or if GraphicsEnvironment.isHeadless() returns trueToolkit.getSystemSelection()
public static java.lang.String getClipboardStringContent()
null
otherwise.public static java.awt.datatransfer.Transferable getClipboardContent()
Transferable
object. Using this method avoids some problems on some platforms.null
if it is not availablepublic static java.awt.datatransfer.Transferable getClipboardContent(java.awt.datatransfer.Clipboard clipboard)
Transferable
object. Using this method avoids some problems on some platforms.clipboard
- clipboard from which contents are retrievednull
otherwise.public static boolean copyString(java.lang.String s)
s
- The string to copy.public static boolean copy(java.awt.datatransfer.Transferable transferable)
transferable
- The transferable to copy.public static java.awt.datatransfer.DataFlavor newDataFlavor(java.lang.Class<?> c, java.lang.String humanPresentableName)
DataFlavor
for the given class and human-readable name.c
- classhumanPresentableName
- the human-readable string used to identify this flavorDataFlavor
for the given class and human-readable namepublic static boolean clear()