gpt4 book ai didi

带有 CFBundleDocumentTypes 的 JavaApplicationStub

转载 作者:行者123 更新时间:2023-11-30 05:12:06 24 4
gpt4 key购买 nike

我正在尝试使用 CFBundleDocumentTypes 将自定义文件扩展名与我的应用程序关联。据我所知,这似乎“有效”——当我双击该文件时,JavaApplicationStub 会启动我的应用程序。但是,没有通过我在 java 中设置的 ApplicationListener 事件注册回调。

我使用了 Set Default file association Mac OS X Java Package Maker Installer 中列出的代码进行文件关联,文件关联本身看起来很好,但似乎是应用程序 stub 试图启动文件,因此失败。

我将 Apple ApplicatinListener 代码添加到我的 java 应用程序中(类似于 http://developer.apple.com/mac/library/documentation/Java/Reference/1.5.0/appledoc/api/index.html?com/apple/eawt/Application.html ),但我的应用程序似乎没有收到回调。

代码类似于

Application.getApplication().addApplicationListener(
new ApplicationAdapter() {
public void handleOpenFile(ApplicationEvent evt) {
//some logging message here that I never get
}
}
);

我也许应该提到我也在使用 SWT...

如有任何帮助,我们将不胜感激

最佳答案

遗憾的是,您无法同时使用 SWT 和 eAWT 的 ApplicationListener。看这个SWT bug 。 SWT 需要 Apple 在 JVM 中进行更改,然后我必须更改 SWT 才能使用它。

由于您对打开文件事件感兴趣,因此您现在可以在所有平台上完全在 SWT 中执行此操作。在 3.6 SWT 中,有一个新事件 SWT.OpenDocument,当双击应用程序的文件时将触发该事件。看这个blog post并搜索“SWT.OpenDocument”。

关于带有 CFBundleDocumentTypes 的 JavaApplicationStub,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3033948/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com