Update README.md

pull/3/head
Hammy 3 years ago
parent 16e55ebf2d
commit 33ceef3d2f

@ -22,7 +22,71 @@ The inspiration for this project came from my frustration of macOS not having cl
built-in unlike Windows. This library will allow you to access the system clipboard and manipulate it.
# Configuration
TODO
Follow the steps below for a basic implementation:
```java
public class Main {
public static void main(String[] args) {
// Retrieve an instance of MyClipboard
MyClipboard myClipboard = MyClipboard.getSystemClipboard();
// Start listening for clipboard notifications
myClipboard.startListening();
// Add event listeners for different types of events (Text, Image & File)
myClipboard.addEventListener((TextEvent) (oldContent, newContent) -> {
String oldText = oldContent.getText();
BufferedImage oldImage = oldContent.getImage();
List<File> oldFiles = oldContent.getFiles();
System.out.println("Old Text: " + oldText);
System.out.println("Old Image: " + oldImage);
System.out.println("Old File: " + oldFiles);
System.out.println("New String Content: " + newContent);
});
myClipboard.addEventListener((ImageEvent) (oldContent, newContent) -> {
String oldText = oldContent.getText();
BufferedImage oldImage = oldContent.getImage();
List<File> oldFiles = oldContent.getFiles();
System.out.println("Old Text: " + oldText);
System.out.println("Old Image: " + oldImage);
System.out.println("Old File: " + oldFiles);
System.out.println("New Image Content: " + newContent);
});
myClipboard.addEventListener((FileEvent) (oldContent, newContent) -> {
String oldText = oldContent.getText();
BufferedImage oldImage = oldContent.getImage();
List<File> oldFiles = oldContent.getFiles();
System.out.println("Old Text: " + oldText);
System.out.println("Old Image: " + oldImage);
System.out.println("Old File" + oldFiles);
System.out.println("New File Content: " + newContent);
});
// Insert into the clipboard
myClipboard.insert("exampleContent");
// Insert and notify MyClipboard of the new content
myClipboard.insertAndNotify("exampleContent");
// Set monitoring for clipboard types
myClipboard.setImageMonitored(true || false);
myClipboard.setTextMonitored(true || false);
myClipboard.setFileMonitored(true || false);
// Toggle monitoring for clipboard types
myClipboard.toggleTextMonitored();
myClipboard.toggleImagesMonitored();
myClipboard.toggleFilesMonitored();
// Stop listening for clipboard notifications
myClipboard.stopListening();
}
}
```
# Windows / *Unix
This approach differs from the macOS section below as Windows/*Unix properly notify the program with global clipboard events.
@ -34,9 +98,6 @@ Unlike the aforementioned event-driven approach, macOS unfortunately is not very
system clipboard has changed. To query the system clipboard contents, we need to employ a polling schedule. I have chosen
**200ms** to ensure that images and large files can be copied over as well as reducing the load on the CPU.
# Contributing
TODO
# Installation
Latest Stable Version: ![maven-central]

Loading…
Cancel
Save