ubuntu - 为 JavaFX 应用程序设置的图标在 Windows 中可见,但在 Ubuntu 中不可见

标签 ubuntu icons javafx-8

这有点奇怪,或者我的代码有问题。

我正在设置 JavaFX 应用程序图标,它在 Windows 系统上非常明显,但在 Ubuntu 上却看不到。

在 Windows 上:

On Taskbar On Window

在 Ubuntu 上:

On Ubuntu unity-panel

关于这背后原因的任何想法。

代码示例:

@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();
    }
}

最佳答案

对于寻找解决方案的人来说,这是 JDK 问题跟踪器中的一个未解决问题。

Gtk: Implement global system menu bar support

根据 JavaFX 开发人员对 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.

在 JavaFX 问题与 JDK 问题合并之前,RT-28202 是上述链接问题的问题 ID。

这个问题的票数非常少,因此没有引起太大兴趣。如果您已注册为贡献者,请随时为该问题投票。

关于ubuntu - 为 JavaFX 应用程序设置的图标在 Windows 中可见,但在 Ubuntu 中不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26039593/

相关文章:

c++ - ubuntu sdk qml 快速查看窗口关闭,最小化按钮不可见

ubuntu - 使用权限设置 webroot 的最安全方法?

css - 情感图标雪碧表?

c++ - WM_GETICON 不工作 (Windows)

JavaFX setCellFactory 未设置我的项目

ruby-on-rails - rails Assets :precompile Yarn executable was not detected in the system

python - 自定义 Python 库仅在 ArchLinux 中引发 ImportError

java - EditText的错误信息图标可以更改吗?

tableview - JavaFX 8 : How to avoid clipped off the text in TableView's column header?

JavaFX - FlowPane 自动调整大小