简体   繁体   English

Java应用程序不知道正在打开的文件的名称 - Mac OS X.

[英]Java application doesn't know name of file being opened - Mac OS X

I have a Java application in an application bundle that has a file association (using Info.plist) that runs when a document is double-clicked. 我在应用程序包中有一个Java应用程序,它有一个文件关联(使用Info.plist),在双击文档时运行。 How do I get the filename of the document that was double-clicked in my Java application? 如何获取在Java应用程序中双击的文档的文件名? Right now my Java app just runs and displays an empty document. 现在我的Java应用程序只运行并显示一个空文档。 There doesn't seem to be any command line arguments passed to the application. 似乎没有任何命令行参数传递给应用程序。

I think you have to implement ApplicationListener or extend ApplicationAdapter and implement the handleOpenFile() method. 我认为你必须实现ApplicationListener或扩展ApplicationAdapter并实现handleOpenFile()方法。 See http://today.java.net/pub/a/today/2004/01/05/swing.html for a more elaborate explanation. 有关更详细的解释,请参见http://today.java.net/pub/a/today/2004/01/05/swing.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM