Java OS X Dock Menu

Can I add items to the application dock menu?

EDIT: I think I skipped the wording of the question, I'm not looking for a way to add an icon to the dock. what I'm looking for when you right-click on the itunes icon, you get itunes control in the menu (pause playback, etc.), I was wondering how to add custom elements to this menu.

+3
source share
2 answers

Take a look at the com.apple.eawt package. In particular, when initializing your application, follow these steps:

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 Java Java Extensions com.apple.eawt, -Apple JDK.

+5

Source: https://habr.com/ru/post/1715846/


All Articles