[英]How do I get my Java App to run from the MacOS desktop menu bar like a status app?
I'm coding with JavaFX 8, and I'm wondering if there is any way I can make my app behave like those apps we often see that run as little icons in the System menu bar so that when you click on it, you just get a small pop-down window but of course with you java program running in it.我正在使用 JavaFX 8 进行编码,我想知道是否有任何方法可以使我的应用程序的行为类似于我们经常看到的那些在系统菜单栏中以小图标运行的应用程序,这样当您单击它时,您只需得到一个小的弹出窗口 window 但当然还有在其中运行的 java 程序。
:-) :-)
Here are some screenshots with an example of what I'm wanting to do.这是一些屏幕截图,其中包含我想要做的示例。
Can this be done with Java?这可以用 Java 完成吗?
Thank you,谢谢,
Michael Sims迈克尔·西姆斯
As far as I know, the only support currently is the SystemTray class of AWT.据我所知,目前唯一支持的是AWT的SystemTray class。
I've seen Swing samples based on that class in the past, and there are JavaFX classes for interoperability between Swing and JavaFX. I've seen Swing samples based on that class in the past, and there are JavaFX classes for interoperability between Swing and JavaFX.
So you might want to try and combine AWT, Swing and JavaFX.因此,您可能想尝试结合 AWT、Swing 和 JavaFX。
I ended up finding a library that solved my problem.我最终找到了一个解决我的问题的库。
JavaFX still does not have a native way of running an app from the title bar (*nix) or the system tray (Windows), but FXTrayIcon is a library that solved this problem for me as it works well enough for my needs given JavaFX's limitations in this regard. JavaFX 仍然没有从标题栏 (*nix) 或系统托盘 (Windows) 运行应用程序的本地方式,但FXTrayIcon是一个库,它为我解决了这个问题,因为考虑到 JavaFX 的限制,它可以很好地满足我的需求在这方面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.