Java OS X dock menu
•
Java
Can I add items to the application dock menu?
Editor: I think I miss this problem. I don't want to find a way to add an icon to the dock What I'm looking for is that when you right-click the iTunes icon, you'll get iTunes controls on the menu (play pause, etc.) I want to know how to add custom items to the menu
Solution
Check out com apple. Eawt package Specifically, please perform the following operations when initializing the application:
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 distribute it as a cross platform application, Apple will send it to com apple. The eawt package provides an apple Java extensions jar with stubs, so the code will be compiled using a non Apple JDK
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码