Java OS X Dock 菜单

发布于 2024-08-02 11:11:44 字数 144 浏览 5 评论 0原文

是否可以将项目添加到应用程序停靠菜单?

编辑:我想我错过了这个问题的措辞,我不是在寻找一种将图标添加到扩展坞的方法。我正在寻找的是,当您右键单击 iTunes 图标时,您可以在菜单上获得 iTunes 控制(播放暂停等),我想知道如何向该菜单添加自定义项目。

Is it possible to add items to the applications dock menu?

EDIT: I think i miss phrased the question, i am not looking for a way to add an icon to the dock. what i am looking for is, when you right click on the itunes icon you get itunes control on the menu (play pause etc) i was wondering how can i add custom items to that menu.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

命硬 2024-08-09 11:11:44

查看 com.apple.eawt 包。具体来说,当您初始化应用程序时,请执行以下操作:

if (System.getProperty("os.name").startsWith("Mac OS X")) {
    // only do this setup if we know this is a Mac
    com.apple.eawt.Application macApp = com.apple.eawt.Application.getApplication();
    java.awt.PopupMenu menu = new java.awt.PopupMenu();
    // create your java.awt.MenuItem objects here
    // add to menu via java.awt.Menu#add(java.awt.MenuItem)
    macApp.setDockMenu(menu);
}

如果您将其作为跨平台应用程序分发,Apple 会提供一个 Apple Java Extensions jar,其中包含 com.apple.eawt 包的存根,因此代码将使用非 Apple JDK。

Look into the com.apple.eawt package. Specifically, when you initialize your app, do something like the following:

if (System.getProperty("os.name").startsWith("Mac OS X")) {
    // only do this setup if we know this is a Mac
    com.apple.eawt.Application macApp = com.apple.eawt.Application.getApplication();
    java.awt.PopupMenu menu = new java.awt.PopupMenu();
    // create your java.awt.MenuItem objects here
    // add to menu via java.awt.Menu#add(java.awt.MenuItem)
    macApp.setDockMenu(menu);
}

If you are distributing this as a cross-platform application, Apple provides an Apple Java Extensions jar with stubs for the com.apple.eawt package, so the code will compile with non-Apple JDKs.

谁对谁错谁最难过 2024-08-09 11:11:44

是的(只要我理解这个问题)。

如果您只是想自定义 Dock 中的 Java 图标,请参阅...
http://developer.apple.com/documentation/Java/Conceptual/Java14Development/03-JavaDeployment/JavaDeployment.html#//apple_ref/doc/uid/TP40001885-208447-TPXREF120

OSX应用程序下的第二点捆绑部分
清楚地标识您的应用程序。(否则,Dock 中会出现默认的 Java 咖啡杯图标。)”

“如果添加适当的图标,它会在 Dock 中显示应用程序图标,从而 您的停靠栏图标的放置事件也位于此处:
http://www.devdaily.com/blog/post/jfc-swing/java-handle-drag-drop-events-mac-osx-dock-application-icon

如果您希望应用程序自动添加它在安装到扩展坞期间使用图标(可能是您的意思)您应该知道没有“官方苹果”方法可以做到这一点,因为在 OS X 上强制您的图标进入用户扩展坞是糟糕的设计,并且通常会令人皱眉。我认识的所有 MAC 用户都会因为此类行为而立即删除您的应用程序。

尽管如此,您可以查看 Apple 网站上的系统管理指南,了解如何以编程方式完成此操作。

Yes (providing I understand the question).

If your just trying to customize the Java Icon in the Dock see ...
http://developer.apple.com/documentation/Java/Conceptual/Java14Development/03-JavaDeployment/JavaDeployment.html#//apple_ref/doc/uid/TP40001885-208447-TPXREF120

Point two under OSX Application Bundles section
"If you add an appropriate icon, it shows the application icon in the Dock, clearly identifying your application. (Otherwise, a default Java coffee cup icon appears in the Dock.)"

There is an example app (Java) for handling drag and drop events for your dock icon as well located here :
http://www.devdaily.com/blog/post/jfc-swing/java-handle-drag-drop-events-mac-osx-dock-application-icon

If you want you application to automatically add it's icon during installation to the dock (possibly what you mean) you should know that there is no "official apple" way to do this as it's BAD design on OS X to force your icons into a users dock, and typically frowned upon. All MAC users i know will instantly remove your application as a result of such behavior.

That said however, you can review the system administration guides on Apple's site to see how it can be done programatically.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文