> On Jan 6, 2023, at 4:35 PM, Michael Hall <[email protected]> wrote:
>
> I haven’t verified if this would further allow changing the java.awt.Desktop
> about handler.
I did check that custom AboutHandlers are possible for OS/X JavaFX
applications.
With…
static {
//java.awt.Toolkit.getDefaultToolkit(); // Start AppKit
Thread t = new Thread(() -> {
java.awt.Toolkit.getDefaultToolkit(); });
t.start();
}
I made the Application class itself the handler…
public class HelloWorld extends Application implements AboutHandler {
Setting the handler seemed to also need some thread management.
@Override
public void init() {
Thread t = new Thread(() -> {
Desktop desktop = Desktop.getDesktop();
desktop.setAboutHandler((AboutHandler)this);
});
t.start();
}
It appeared this could be done in the init or about anywhere in the javaFX
start method.
The handler I think comes in on the AWT EventQueue so needs to be changed to
javaFX
public void handleAbout(AboutEvent evt) {
System.out.println("got to handleAbout");
Platform.runLater(() -> {
Alert alert = new Alert(AlertType.INFORMATION, "About
HelloWorld");
alert.showAndWait();
});
}
Checking on Windows 10 VirtualBox it appeared Desktop.Action.APP_ABOUT isn’t
supported.
I had trouble with my VirtualBox linux images so didn’t verify there but I’m
guessing this is viewed as OS/X only and not supported there either.
I never really did determine why javaFX applications are different. My last
thought had been that they instantiated an NSApplication early so a
NSApplicationAWT wss never obtained. However, I later thought I saw where I
passed a check indicating I had to have NSApplicationAWT. With a fix so you get
the About menu item it seemed a little moot. What I provided for
ApplicationDelegate seems to be one such fix. You can come up with your own fix
but I think it will need to done jdk side though to provide this functionality
to javafx app’s. I might bring this up on the javafx list if the jdk does make
it possible at some point.
I haven’t looked at any other Desktop functionality for javafx app’s yet having
no immediate need myself.