An open API service indexing awesome lists of open source software.

https://github.com/caoimhebyrne/jnapple

🍏 A collection of partial JNA bindings for various macOS frameworks. (e.g. Foundation, AppKit, etc.)
https://github.com/caoimhebyrne/jnapple

bindings java jna macos

Last synced: 5 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# 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](https://github.com/cbyrneee/JNApple/tree/main/src/test/java/dev/cbyrne/jnapple/test).

**Creating an NSString**

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

**Creating an NSURL**

```java
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**

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

**Opening a file picker (NSOpenPanel)**

```java
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);
}
```