cbyrneee / JNApple

🍏 A collection of partial JNA bindings for various macOS frameworks. (e.g. Foundation, AppKit, etc.)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JNApple

🍏 A collection of partial JNA bindings for various macOS frameworks. (e.g. Foundation, AppKit, etc.)

Usage

These are just some common examples, for a wider range, check out our tests.

Creating an NSString

var str = new NSString("Hello, World!");
// You can access this as a Java String if you wish too! (NSString#getJvmString)

Creating an NSURL

var str = new NSURL("https://cbyrne.dev");
// You can access this as a Java URL if you wish too! (NSURL#getJvmURL)

Copying text to the clipboard

var pasteboard = NSPasteboard.generalPasteboard();
pasteboard.clearContents();
pasteboard.setString("Hello, World!", NSPasteboard.TypeString);

Opening a file picker (NSOpenPanel)

var panel = NSOpenPanel.openPanel();
panel.setCanChooseFiles(true);

var result = panel.runModal();
if(result == NSAlert.NSModalResponse.OK) {
    NSURL url = panel.getURLs().objectAtIndex(0); // Can also use firstObject()
    System.out.println("First URL: " + url);
}

About

🍏 A collection of partial JNA bindings for various macOS frameworks. (e.g. Foundation, AppKit, etc.)

License:MIT License


Languages

Language:Java 97.3%Language:Kotlin 1.6%Language:Shell 1.1%