Skip to content

Instantly share code, notes, and snippets.

@Jomy10
Last active January 15, 2022 18:49
Show Gist options
  • Save Jomy10/865b78b930c7148cb1e1fbc699943786 to your computer and use it in GitHub Desktop.
Save Jomy10/865b78b930c7148cb1e1fbc699943786 to your computer and use it in GitHub Desktop.
This class lets you customise the about menu for Mac users (Java/JavaFX)
// When you call new HandleAboutMac(), it will set the action on what has to be done when a Mac user selects the about menu
// in [your app name] > about [your app name]
public class HandleAboutMac {
public HandleAboutMac() {
com.apple.eawt.Application application = com.apple.eawt.Application.getApplication();
application.setAboutHandler(new AboutHandler() {
@Override
public void handleAbout(AppEvent.AboutEvent aboutEvent) {
// This is where your code goes for what has to be done when a Mac user selects the about menu
// For example:
JOptionPane.showMessageDialog(null, "YOUR APP NAME\nYOUR APP INFO");
// If you want to use JavaFX, you'll need to use the Platform.runLater;
// Platform.runLater(new Runnable() {
// @Override
// public void run() {
// // Your JFX code here
// }
// });
}
});
}
}
// Hope this helped!
@Jomy10
Copy link
Author

Jomy10 commented Mar 23, 2021

With this java code, you can handle what has to be done when a Mac user goes to the about tab in your .jar program.
Leave a comment if this helped you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment