Last active
January 15, 2022 18:49
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 :)