Class ClipboardUtils
- java.lang.Object
-
- org.openstreetmap.josm.gui.datatransfer.ClipboardUtils
-
public final class ClipboardUtils extends java.lang.Object
This is a utility class that provides methods useful for general data transfer support.- Since:
- 10604
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classClipboardUtils.DoNothingClipboardOwner
-
Field Summary
Fields Modifier and Type Field Description private static java.awt.datatransfer.Clipboardclipboard
-
Constructor Summary
Constructors Modifier Constructor Description privateClipboardUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanclear()Clears the system clipboard.static booleancopy(java.awt.datatransfer.Transferable transferable)Copies the given transferable to the clipboard.static booleancopyString(java.lang.String s)Copy the given string to the clipboard.static java.awt.datatransfer.ClipboardgetClipboard()This method should be used from all of JOSM to access the clipboard.static java.awt.datatransfer.TransferablegetClipboardContent()Extracts clipboard content asTransferableobject.static java.awt.datatransfer.TransferablegetClipboardContent(java.awt.datatransfer.Clipboard clipboard)Extracts clipboard content asTransferableobject.static java.lang.StringgetClipboardStringContent()Gets the clipboard content as string.static java.awt.datatransfer.ClipboardgetSystemSelection()Gets the singleton instance of the system selection as aClipboardobject.static java.awt.datatransfer.DataFlavornewDataFlavor(java.lang.Class<?> c, java.lang.String humanPresentableName)Returns a newDataFlavorfor the given class and human-readable name.
-
-
-
Field Detail
-
clipboard
private static java.awt.datatransfer.Clipboard clipboard
-
-
Constructor Detail
-
ClipboardUtils
private ClipboardUtils()
-
-
Method Detail
-
getClipboard
public static java.awt.datatransfer.Clipboard getClipboard()
This method should be used from all of JOSM to access the clipboard.It will default to the system clipboard except for cases where that clipboard is not accessible.
- Returns:
- A clipboard.
- See Also:
getClipboardContent()
-
getSystemSelection
public static java.awt.datatransfer.Clipboard getSystemSelection()
Gets the singleton instance of the system selection as aClipboardobject. This allows an application to read and modify the current, system-wide selection.- Returns:
- the system selection as a
Clipboard, ornullif the native platform does not support a system selectionClipboardor if GraphicsEnvironment.isHeadless() returns true - See Also:
Toolkit.getSystemSelection()
-
getClipboardStringContent
public static java.lang.String getClipboardStringContent()
Gets the clipboard content as string.- Returns:
- the content if available,
nullotherwise.
-
getClipboardContent
public static java.awt.datatransfer.Transferable getClipboardContent()
Extracts clipboard content asTransferableobject. Using this method avoids some problems on some platforms.- Returns:
- The content or
nullif it is not available
-
getClipboardContent
public static java.awt.datatransfer.Transferable getClipboardContent(java.awt.datatransfer.Clipboard clipboard)
Extracts clipboard content asTransferableobject. Using this method avoids some problems on some platforms.- Parameters:
clipboard- clipboard from which contents are retrieved- Returns:
- clipboard contents if available,
nullotherwise.
-
copyString
public static boolean copyString(java.lang.String s)
Copy the given string to the clipboard.- Parameters:
s- The string to copy.- Returns:
- True if the copy was successful
-
copy
public static boolean copy(java.awt.datatransfer.Transferable transferable)
Copies the given transferable to the clipboard. Handles state problems that occur on some platforms.- Parameters:
transferable- The transferable to copy.- Returns:
- True if the copy was successful
-
newDataFlavor
public static java.awt.datatransfer.DataFlavor newDataFlavor(java.lang.Class<?> c, java.lang.String humanPresentableName)
Returns a newDataFlavorfor the given class and human-readable name.- Parameters:
c- classhumanPresentableName- the human-readable string used to identify this flavor- Returns:
- a new
DataFlavorfor the given class and human-readable name - Since:
- 10801
-
clear
public static boolean clear()
Clears the system clipboard.- Returns:
- True if the clear was successful
- Since:
- 14500
-
-