It is a bit weird or maybe there is something wrong with my code.
I am setting JavaFX application ICON which is very well visible on Windows system but not on Ubuntu.
On Windows:
On Ubuntu:
Any idea about the reason behind this.
Code Sample:
@Override
public void start(Stage stage) throws Exception {
try {
setUserAgentStylesheet(STYLESHEET_MODENA);
FXMLLoader loader = new FXMLLoader();
Parent root = (Parent) loader.load(getClass().getResourceAsStream("ui/ParentWindow.fxml"));
final ParentWindowController controller = (ParentWindowController) loader.getController();
stage.addEventHandler(WindowEvent.WINDOW_SHOWN, controller::handleWindowShownEvent);
stage.addEventHandler(WindowEvent.WINDOW_SHOWING, controller::handleWindowShowingEvent);
stage.addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, controller::handleWindowClosingRequestedEvent);
Scene scene = new Scene(root);
scene.getStylesheets().setAll(
getClass().getResource("ui/css/ParentWindow.css").toExternalForm()
);
stage.setScene(scene);
stage.initStyle(StageStyle.UNIFIED);
stage.setResizable(false);
stage.toFront();
stage.setTitle("Simple JavaFX Tool");
stage.getIcons().add(new Image(getClass().getResourceAsStream("resources/images/icon.jpg")));
stage.show();
} catch (IOException iOException) {
iOException.printStackTrace();
}
}
For people looking for solution, this is an open issue in the JDK issue tracker.
Gtk: Implement global system menu bar support
According to a comment by JavaFX developer on a similar issue :
Glass/FX currently doesn't support the global menu bar on GTK (RT-28202). As such, Glass doesn't set any application-wide hints to specify the application name or application icon. The desktop environment has to guess them itself (likely, using a window's title and icon). Hence, it is correct that the "app window" (#1 above) should always display the correct title, while the other 3 places may or may not display the correct title depending on timings. This is unlikely to change until RT-28202 is implemented.
RT-28202 was the issue id for the above linked issue before JavaFX issues was merged with JDK issues.
This issue has a very less no of votes and therefore hasn't attracted much interest. If you are registered as a contributor, feel free to vote for the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With