问题描述
我有一个Windows程序,其中包含以下流程:
I have a Windows program with the following flow:
generated config file -> user edits config file -> use config file
理想情况下,我想为给定的文件类型/扩展名启动系统默认编辑器(。 cfg,.ini,.txt),可以使用。
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 :\
我已经看到这可以在数字应用程序中完成,虽然大多数在Linux上,可能是非java。
I have seen this be done in numeous applications, albeit most on Linux and probably non-java.
此外,由于用户愚蠢,配置默认编辑器在我的申请中太复杂了。使用标准程序可能是可以接受的,例如确保几乎的记事本始终安装在Windows计算机上。
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.
推荐答案
刚想出记事本解决方案 - doh!很明显:))
Just figured out the notepad solution -- doh! it was quite obvious :)
使用和:
Process p = Runtime.getRuntime.exec("notepad " + filename);
p.waitFor();
这篇关于在java中捕获系统默认编辑器关闭事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!