๐Ÿ“ฆ amake / DesktopSupport

A library to bridge Apple Java Extensions and JEP 272 desktop APIs

โ˜… 5 stars โ‘‚ 2 forks ๐Ÿ‘ 5 watching โš–๏ธ Apache License 2.0
applejavajep-272
๐Ÿ“ฅ Clone https://github.com/amake/DesktopSupport.git
HTTPS git clone https://github.com/amake/DesktopSupport.git
SSH git clone git@github.com:amake/DesktopSupport.git
CLI gh repo clone amake/DesktopSupport
Aaron Madlon-Kay Aaron Madlon-Kay v0.7.0-SNAPSHOT 47cae52 4 years ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ example
๐Ÿ“ gradle
๐Ÿ“ lib
๐Ÿ“ lib-api
๐Ÿ“ lib-apple
๐Ÿ“ lib-java9
๐Ÿ“„ .gitignore
๐Ÿ“„ build.gradle
๐Ÿ“„ gradlew
๐Ÿ“„ gradlew.bat
๐Ÿ“„ LICENSE
๐Ÿ“„ Makefile
๐Ÿ“„ README.md
๐Ÿ“„ settings.gradle
๐Ÿ“„ README.md

DesktopSupport Library for Java

This library bridges the Apple Java Extensions APIs and the JEP 272 desktop APIs added in Java 9. It is intended for use by applications that want to support running on both Java 8 and Java 11.

Implementation

This library wraps a subset of the com.apple.eawt.Application API and delegates to whichever actual implementation is available: Apple or Java 9+, or a dummy no-op implementation if neither.

Thus it is safe to call the API anywhere, without checking the platform first. Note, however, that listeners and handlers will never be called under the no-op implementation, so critical logic must not be placed there.

Java versionPlatformImplementation
Java 8macOScom.apple.eawt.*
Java 8OtherNo-op
Java 11Anyjava.awt.*

Coverage

  • Non-deprecated methods on com.apple.eawt.Application
  • Methods on com.apple.eawt.FullScreenUtilities
  • UIManager#createLookAndFeel from Java 9+

Requirements

Java 8+ is required to run.

Java 11 is required in order to build.

Usage

Add the dependency:

implementation 'org.madlonkay:desktopsupport:+'

Call methods on DesktopSupport.getSupport():

DesktopSupport.getSupport().disableSuddenTermination();
DesktopSupport.getSupport().setAboutHandler(e -> {
    // handle About event
});

The API is meant to mostly match the ones it wraps, but it is not quite a drop-in replacement:

  • Event objects that have no methods or payloads (e.g. AboutEvent) are just
EventObject
  • FullScreenUtilities (Apple) and Taskbar/GraphicsEnvironment/etc. (Java
9) methods are on IDesktopSupport with everything else rather than in a separate class

License

Apache 2.0