在java中捕获系统默认编辑器关闭事件
我有一个具有以下流程的 Windows 程序:
generated config file -> user edits config file -> use config file
理想情况下,我想启动给定文件类型/扩展名(.cfg、.ini、.txt)的系统默认编辑器,这可以通过 java.awt.Desktop.edit()
。
但是,由于编辑器启动后程序会继续执行,所以我不知道如何检查用户是否确实再次关闭了编辑器 :\
我已经在许多应用程序中看到过这种情况,尽管大多数在 Linux 上并且可能非java。
另外,由于用户是“愚蠢的”,因此从我的应用程序中配置默认编辑器太复杂了。使用标准程序可能是可以接受的,例如记事本,它可以确保几乎始终安装在Windows 计算机上。
I have a Windows program with the following flow:
generated config file -> user edits config file -> use config file
Ideally I want to launch the system default editor for the given file type/extension (.cfg, .ini, .txt), which can be done with java.awt.Desktop.edit()
.
But since the program continues execution once the editor has started, I have no idea how to check that the user actually closed the editor again :\
I have seen this be done in numeous applications, albeit most on Linux and probably non-java.
Also, since users are "stupid", configuring a default editor from within my application is way too complicated. It might be acceptable to use a standard program, e.g. notepad which is ensured to almost always be installed on Windows computers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
刚刚找到了记事本解决方案——哦!这很明显:)
使用
Runtime.exec()
和Process.waitFor()
:Just figured out the notepad solution -- doh! it was quite obvious :)
Use
Runtime.exec()
andProcess.waitFor()
: