Constructor and Description |
---|
ClipboardHelper() |
Modifier and Type | Method and Description |
---|---|
static String |
getHTML(Clipboard clipboard)
Returns the "text/html" string contained in the clipboard
if any;
null otherwise. |
static Image |
getImage(Clipboard clipboard)
Returns the image contained in the clipboard if any;
null otherwise. |
static String |
getSelection(Clipboard clipboard)
Returns the system selection if any;
null otherwise. |
static String |
getString(Clipboard clipboard)
Returns the string contained in the clipboard if any;
null otherwise. |
static Clipboard |
getSystemClipboard()
Returns the system clipboard if the environment is not headless;
a shared clipboard, private to the application, otherwise.
|
static Clipboard |
getSystemSelection()
Returns the system selection if this is supported by the platform
(example: Linux/X11) and if the environment is not headless;
a shared clipboard, private to the application, otherwise.
|
static boolean |
hasHTML(Clipboard clipboard)
Tests whether the clipboard contains a "text/html" string.
|
static boolean |
hasImage(Clipboard clipboard)
Tests whether the clipboard contains a image.
|
static boolean |
hasSelection(Clipboard clipboard)
Tests whether the system selection has been set.
|
static boolean |
hasString(Clipboard clipboard)
Tests whether the clipboard contains a string.
|
static void |
reportError(String message,
Throwable t) |
static boolean |
setImage(Clipboard clipboard,
Image image)
Copies specified image to the clipboard.
|
static boolean |
setSelection(Clipboard clipboard,
String s)
Sets the system selection to specified string.
|
static boolean |
setString(Clipboard clipboard,
String s)
Copies specified string to the clipboard.
|
public static Clipboard getSystemClipboard()
GraphicsEnvironment.isHeadless()
public static boolean setString(Clipboard clipboard, String s)
clipboard
- the clipboard being used; null
to
specify the system clipboards
- string to be copied to the clipboardtrue
if the string has been successfully copied to
the clipboard; false
otherwise (clipboard busy or
null
string)public static boolean hasString(Clipboard clipboard)
clipboard
- the clipboard being used; null
to
specify the system clipboardpublic static String getString(Clipboard clipboard)
null
otherwise.clipboard
- the clipboard being used; null
to
specify the system clipboardpublic static boolean hasHTML(Clipboard clipboard)
clipboard
- the clipboard being used; null
to
specify the system clipboardpublic static String getHTML(Clipboard clipboard)
null
otherwise.
Beware that the returned HTML may be vastly incorrect. For example, MS-Word copies vastly incorrect HTML to the clipboard. Moreover, this HTML may start with the following kind of plain text ``header'':
Version:1.0 StartHTML:0000000186 EndHTML:0000486344 ...
clipboard
- the clipboard being used; null
to
specify the system clipboardpublic static Clipboard getSystemSelection()
GraphicsEnvironment.isHeadless()
public static boolean setSelection(Clipboard clipboard, String s)
clipboard
- the clipboard being used; null
to
specify the system selections
- string to be copied to the system selectiontrue
if the string has been successfully copied to
the system selection; false
otherwise (system selection
busy or null
string)public static boolean hasSelection(Clipboard clipboard)
clipboard
- the clipboard being used; null
to
specify the system selectionpublic static String getSelection(Clipboard clipboard)
null
otherwise.clipboard
- the clipboard being used; null
to
specify the system selectionpublic static boolean setImage(Clipboard clipboard, Image image)
image
- image to be copied to the clipboardtrue
if the image has been successfully copied to
the clipboard; false
otherwise (clipboard busy or
null
image)public static boolean hasImage(Clipboard clipboard)
public static Image getImage(Clipboard clipboard)
null
otherwise.AWTUtil.toBufferedImage(java.awt.Image)