缺少Mac上的JavaFX OpenFilesEvent [英] Missing OpenFilesEvent for JavaFX on Mac

查看:585
本文介绍了缺少Mac上的JavaFX OpenFilesEvent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JavaFX 8桌面应用程序,我正在创建一个 .app 应用程序包,以将应用程序分发给Mac用户。我使用Oracle自包含应用程序打包工具生成捆绑包。

I have a JavaFX 8 desktop application and I'm creating an .app application bundle to distribute the application to Mac users. I use the Oracle "Self-Contained Application Packaging" tool to generate the bundle.

我遇到的问题与我的应用程序关联的文件有关。我正在将扩展 .wordy 与这些文件相关联。如果我打开了应用程序,并在Mac Finder中双击其中一个文件,我的应用程序会收到一个 OpenFilesEvent ,其中包含文件的路径,一切正常。但是,如果应用程序未打开,双击Finder中的 .wordy 文件会打开我的应用程序,但我从未收到包含该路径的事件。用户双击的文件。

The problem that I have relates to the files associated with my application. I am associating the extension .wordy with these files. If I have the application open and I double click one of these files in the Mac Finder, my application receives an OpenFilesEvent containing the path to the file and everything works perfectly. If, however, the application is not open, double clicking a .wordy file in the Finder opens my application as I would expect but I never receive the event containing the path to the file that the user double-clicked on.

文件关联在Oracle自包含应用程序打包工具的Ant脚本中完成,如下所示:

The file association is done in the Ant script for the Oracle "Self-Contained Application Packaging" tool, as follows:

<project name="VocabHunter Packaging" basedir=""
         xmlns:fx="javafx:com.sun.javafx.tools.ant">
    ...
    <fx:info title="VocabHunter">
        <fx:association description="VocabHunter session"
                        extension="wordy"
                        mimetype="application/x-vnd.VocabHunterSession"
                        icon="${basedir}/icons/mac/VocabHunterSession.icns"/>
    </fx:info>
    ...
</project>

在Java代码中,我获得了一个的实例com.apple.eawt .Application 然后注册 OpenFilesEvent 的监听器,如下所示:

In the Java code, I obtain an instance of com.apple.eawt.Application and then register the listener for the OpenFilesEvent as follows:

Application application = Application.getApplication();
application.setOpenFileHandler(new OsxOpenFilesHandler(listener));

您可以看到完整的代码这里

You can see the full code here.

有谁知道如何解决这个问题,以便我收到一个包含 .wordy 文件的路径,即使应用程序在双击文件时没有运行?

Does anyone know how to fix this so that I receive an event containing the path to the .wordy file even if the application was not running at the moment that the file was double clicked?

为了完整性,我正在使用Oracle JDK 1.8.0_66 for Mac。

In the interests of completeness, I'm using the Oracle JDK 1.8.0_66 for Mac.

推荐答案

有一个条目这个问题的bug数据库。
https://bugs.openjdk.java.net/browse/JDK- 8187992

There is an entry in the bug database for this issue. https://bugs.openjdk.java.net/browse/JDK-8187992

这篇关于缺少Mac上的JavaFX OpenFilesEvent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆