如何将 Java 应用程序置于 Mac 上的前端?
我有一个 Java 应用程序,我想定期将其置于前台,但我一直无法做到这一点。
[除了那些想要提供用户界面建议的人。是的,这通常很可怕,但我是唯一一个使用该应用程序的人。这是我的时间和计费应用程序,我厌倦了无法记录计费时间!]
我尝试过使用 AppleScript,并且使用以下脚本让 Firefox 执行此操作没有问题:
tell application "Firefox"
repeat
activate
delay 10
end repeat
end tell
但我不知道如何引用AppleScript 中的 Java 应用程序(也就是说,我不知道该应用程序的名称应包含什么内容)。
tell application "java"
不起作用(并且可能有多个 Java 应用程序正在运行)。告诉应用程序“NameShowingInMenu”
也不起作用。- 我尝试过设置“-Xdoc:name”,它适用于设置菜单中显示的名称,但不适用于“tell”目标。
有什么想法吗?
I have a Java application that I want to bring to the front at regular intervals, but I haven't been able to do this.
[Aside to people wanting to offer user interface advice. Yes, this is normally horrible, but I'm the only one using the app. It's my time&billing app, and I'm tired failing to record billable hours!]
I've tried with AppleScript, and have no problem getting Firefox to do this, with the following script:
tell application "Firefox"
repeat
activate
delay 10
end repeat
end tell
But I don't know how reference a Java app in AppleScript (that is, I don't know what to put for the appication's name).
tell application "java"
doesn't work (and there may be several Java apps running).tell application "NameShowingInMenu"
doesn't work, either.- I've tried setting "-Xdoc:name", that works for setting the name shown in the menu, but not for a "tell" target.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我能够使用 Max OS X 中附带的“Jar Bundler”应用程序来做到这一点。
一旦我使用它打包了我的代码,它就表现得像一个标准的 Mac 应用程序,并且我原来问题中的脚本工作没有问题。
I was able to do this, using the "Jar Bundler" app, which is included with Max OS X.
Once I packaged my code using that, it behaved as a standard mac application and the script in my original question worked with no problems.
如果您可以在 Java 应用程序本身中执行此操作,则可以从以下位置获得提示:
如何将窗口置于前面?
If you can do this in the Java app itself, you could get a hint from:
How to bring a window to the front?