简体   繁体   English

如何让我的 Java 应用程序像状态应用程序一样从 MacOS 桌面菜单栏运行?

[英]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.

相关问题 如何在Java应用程序的底部创建一个条,如状态栏? - How can I create a bar in the bottom of a Java app, like a status bar? 如何设置从我的 Java 应用程序启动的 MacOS 应用程序包的工作目录? - What do I set the working directory of a MacOS app bundle launched from my Java app? 如何将桌面Java应用程序连接到在线数据库(用于虚拟人)? - How do I connect a desktop java app to an online database (for dummies)? 我如何让我的应用程序运行我在桌面上使用 eclipse 创建它,但它不会在我的笔记本电脑上运行? - how do i get my application to run i created it using eclipse on my desktop but it will not run on my laptop? 如何从我的 Java 应用程序与控制台应用程序交互? - How do I interact with a console application from my Java app? 如何将 JMenuBar 添加到 macOS 的屏幕菜单栏 - How do i add JMenuBar to the Screen Menu Bar in macOS 如何从菜单栏中打开框架 - how do i open a frame from my menu bar 如何将在终端中运行的Java应用程序转换为具有UI的桌面应用程序? - How can I turn my Java app that runs in a terminal into a desktop app with a UI? 我如何获得这个Java应用程序的PID? - How do I get the PID of this Java app? 如何在桌面上创建一个下拉菜单Java应用程序以容纳桌面图标(java) - how to create a drop down menu java app on the desktop to hold desktop icons (java)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM