use of org.pushingpixels.flamingo.api.common.AsynchronousLoadListener in project freeplane by freeplane.
the class MenuBuilder method addMenuItem.
public void addMenuItem(final String relativeKey, final JMenuItem item, final String key, final int position) {
// RIBBONS - to set the right icon size
if (item.getIcon() != null && item.getIcon() instanceof ImageIcon) {
ImageIcon ico = (ImageIcon) item.getIcon();
ImageWrapperResizableIcon newIco = ImageWrapperResizableIcon.getIcon(ico.getImage(), new Dimension(ico.getIconWidth(), ico.getIconHeight()));
newIco.setPreferredSize(new Dimension(16, 16));
newIco.addAsynchronousLoadListener(new AsynchronousLoadListener() {
public void completed(boolean success) {
item.repaint();
}
});
item.setIcon(newIco);
}
final Node element = (Node) addElement(relativeKey, item, key, position);
if (null == getMenuBar(element)) {
return;
}
AFreeplaneAction action = (item.getAction() instanceof AccelerateableAction ? ((AccelerateableAction) item.getAction()).getOriginalAction() : (AFreeplaneAction) item.getAction());
actionNodeMap.put(action, element);
// }
if (action != null) {
KeyStroke acceleratorKeyStroke = acceleratorManager.getAcceleratorKeyStroke(action);
if (acceleratorKeyStroke != null) {
acceleratorManager.setAccelerator(action, acceleratorKeyStroke);
item.setAccelerator(acceleratorKeyStroke);
}
}
}
Aggregations