Skip to content

amake/DesktopSupport

Repository files navigation

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 version Platform Implementation
Java 8 macOS com.apple.eawt.*
Java 8 Other No-op
Java 11 Any java.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

About

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

Topics

Resources

License

Stars

5 stars

Watchers

0 watching

Forks

Sponsor this project

  •  

Packages

 
 
 

Contributors