I add a menu to a toolbar like this :
JMenuBar menu = new JMenuBar();
JMenu actions = new JMenu("Aktionen");
Icon menuIcon = ImageUtilities.loadImageIcon("pathToIcon", true);
actions.setIcon(menuIcon);
// Add
JMenuItem addItem = new JMenuItem("Add");
Icon addIcon = ImageUtilities.loadImageIcon("pathToIcon", true);
addItem.setIcon(addIcon);
addItem.setToolTipText("Add new Item");
addItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
AddItemAction someAction = new AddItemAction();
someAction.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, null) {
// Foo
});
}
});
menu.add(actions);
actions.add(addItem);
toolbar.addSeparator();
toolbar.add(menu);
Basically, it works fine. But, it never displays the tooltip ("Add new Item"). Any hints ?
EDIT: Just in case someone with the same problem stumbles upon this: it was the L&F, as I should have suspected from the beginning. It has a property for displaying tooltips of JMenuItems ; and it defaults to false.