Socket
Socket
Sign inDemoInstall

com.github.fracpete:jclipboardhelper

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.github.fracpete:jclipboardhelper

Helper library for dealing with the System clipboard in Java.


Version published
Maintainers
1
Source

jclipboardhelper

Helper library for dealing with the sytem's clipboard in Java.

Maven

You can use the following dependency in your pom.xml:

<dependency>
  <groupId>com.github.fracpete</groupId>
  <artifactId>jclipboardhelper</artifactId>
  <version>0.1.2</version>
</dependency>

Supported formats

  • Copy to clipboard

    • java.lang.String
    • java.awt.image.BufferedImage
    • javax.swing.JComponent -- creates images from it
    • javax.swing.JTable -- call the table's copy action
    • java.awt.datatransfer.Transferable -- supply your own implementation
  • Paste from clipboard

    • java.lang.String
    • java.awt.image.BufferedImage
    • java.awt.datatransfer.Transferable -- returns just an Object

Example usage

Example code for copying data to the clipboard:

import java.awt.image.BufferedImage;
import com.github.fracpete.jclipboardhelper.ClipboardHelper;
...
// string
ClipboardHelper.copyToClipboard("Hello World");
// image
BufferedImage img = ...  // from somewhere
ClipboardHelper.copyToClipboard(img);

Example code for obtaining data from the clipboard:

import java.awt.image.BufferedImage;
import com.github.fracpete.jclipboardhelper.ClipboardHelper;
...
// string available?
if (ClipboardHelper.canPasteStringFromClipboard()) {
  String s = ClipboardHelper.pasteStringFromClipboard();
}
// image available?
if (ClipboardHelper.canPasteImageFromClipboard()) {
  BufferedImage img = ClipboardHelper.pasteImageFromClipboard();
}

Example for clearing the clipboard:

import com.github.fracpete.jclipboardhelper.ClipboardHelper;
...
ClipboardHelper.clearClipboard();

FAQs

Package last updated on 05 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc