Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX: Problem with useSystemMenuBar when starting with -splash option

Tags:

java

javafx

I am using OpenJFX under Mac OS X and I observed a strange behaviour of my application.

My environment is

Software Version
OS OS X El Capitan (10.11.6)
Java openjdk version "15" 2020-09-15
OpenJDK Runtime Environment AdoptOpenJDK (build 15+36)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 15+36, mixed mode, sharing)
OpenJFX 15.0.1

My application uses the system menu bar of Mac OS X by

menuBar.setUseSystemMenuBar(true)

When starting my application from command line with Java everything works fine. When I add the -splash option on start the menu is appearing inside the application instead of the Mac OS system menu.

I think this might be a bug of Java itself or Java FX, I am not sure.

My demo application is built from two classes

public class Launcher {
    public static void main(String[] args) {
        MyApp.runApp(args);
    }
}

and

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class MyApp extends Application {
    @Override
    public void start(Stage primaryStage) throws Exception {
        String javaVersion = System.getProperty("java.version");
        String javafxVersion = System.getProperty("javafx.version");
        Label l = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + ".");
        MenuBar menuBar = new MenuBar(new Menu("TEST"));
        menuBar.setUseSystemMenuBar(true);
        Scene scene = new Scene(new VBox(menuBar, new StackPane(l)), 640, 480);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public static void runApp(String[] args) {
        launch(args);
    }
}

When invoked without -splash the application supports the system menu bar

My demo app with system menu bar

When invoked with -splash option the menu is located inside the application

My demo app ignoring system menu bar

Has anybody seen similar behaviour? Do you know whether there is a bug filed already against Open Java oder Open JavaFX? I did not find anything.

What do you think is the right project to file a bug against, Open Java or Open Java FX?

Thanks in advance Thorsten

like image 732
Thorsten Avatar asked Dec 06 '25 06:12

Thorsten


1 Answers

I asked the developers from Open FX news group and they forwarded me to the Java bug parade.

There is already an open bug in the list: https://bugs.openjdk.java.net/browse/JDK-8153381

This issue is nearly 5 years old, priority 4, so only small chances to get a fix soon.

like image 122
Thorsten Avatar answered Dec 07 '25 18:12

Thorsten