Class ClipboardUtils

java.lang.Object
org.openstreetmap.josm.gui.datatransfer.ClipboardUtils

public final class ClipboardUtils extends Object
This is a utility class that provides methods useful for general data transfer support.
Since:
10604
  • Field Details

  • Constructor Details

  • Method Details

    • getClipboard

      public static 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:
    • getSystemSelection

      public static Clipboard getSystemSelection()
      Gets the singleton instance of the system selection as a Clipboard object. This allows an application to read and modify the current, system-wide selection.
      Returns:
      the system selection as a Clipboard, or null if the native platform does not support a system selection Clipboard or if GraphicsEnvironment.isHeadless() returns true
      See Also:
    • getClipboardStringContent

      Gets the clipboard content as string.
      Returns:
      the content if available, null otherwise.
    • getClipboardContent

      Extracts clipboard content as Transferable object. Using this method avoids some problems on some platforms.
      Returns:
      The content or null if it is not available
    • getClipboardContent

      public static Transferable getClipboardContent(Clipboard clipboard)
      Extracts clipboard content as Transferable object. Using this method avoids some problems on some platforms.
      Parameters:
      clipboard - clipboard from which contents are retrieved
      Returns:
      clipboard contents if available, null otherwise.
    • copyString

      public static boolean copyString(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(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 DataFlavor newDataFlavor(Class<?> c, String humanPresentableName)
      Returns a new DataFlavor for the given class and human-readable name.
      Parameters:
      c - class
      humanPresentableName - the human-readable string used to identify this flavor
      Returns:
      a new DataFlavor for 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