本文整理了Java中javax.swing.JMenu.setIcon()
方法的一些代码示例,展示了JMenu.setIcon()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenu.setIcon()
方法的具体详情如下:
包路径:javax.swing.JMenu
类名称:JMenu
方法名:setIcon
暂无
代码示例来源:origin: org.bidib.org.oxbow/swingbits
@Override
public JMenuItem add(JMenuItem menuItem) {
Component c = target.add(menuItem);
if ( c instanceof JMenu ) {
((JMenu)c).setIcon(null);
}
return menuItem;
}
代码示例来源:origin: eugener/oxbow
@Override
public JMenuItem add(JMenuItem menuItem) {
Component c = target.add(menuItem);
if ( c instanceof JMenu ) {
((JMenu)c).setIcon(null);
}
return menuItem;
}
代码示例来源:origin: com.dorkbox/SystemTray
@Override
public
void run() {
File imageFile = menuItem.getImage();
if (imageFile != null) {
ImageIcon origIcon = new ImageIcon(imageFile.getAbsolutePath());
((JMenu) _native).setIcon(origIcon);
}
else {
((JMenu) _native).setIcon(null);
}
}
});
代码示例来源:origin: stackoverflow.com
JMenu mFoo = new JMenu("Foo");
mFoo.setIcon(new ImageIcon("icon.png"));
JMenuBar menuBar = new JMenuBar();
menuBar.add(mFoo);
setJMenuBar(menuBar);
代码示例来源:origin: com.synaptix/SynaptixWidget
@Override
public IPopupMenuActionsBuilder addSubPopupMenu(Icon icon, String name) {
JMenu menu = new JMenu(name);
menu.setIcon(icon);
menu.add(menu);
return new SubPopupMenuActionsBuilder(menu);
}
}
代码示例来源:origin: otros-systems/otroslogviewer
private JMenu[] getAutomaticMarkersMenu() {
// AutomaticMarker[] markers = MarkersContainer.getInstance().getMarkers().toArray(new AutomaticMarker[0]);
automaticMarkersMenu = new JMenu("Mark rows automatically");
automaticMarkersMenu.setIcon(Icons.AUTOMATIC_MARKERS);
automaticUnmarkersMenu = new JMenu("Unmark rows automatically");
automaticUnmarkersMenu.setIcon(Icons.AUTOMATIC_UNMARKERS);
updateMarkerMenu(markersContainer.getElements());
return new JMenu[]{automaticMarkersMenu, automaticUnmarkersMenu};
}
代码示例来源:origin: com.synaptix/SynaptixWidget
@Override
public IPopupMenuActionsBuilder addSubPopupMenu(Icon icon, String name) {
JMenu menu = new JMenu(name);
menu.setIcon(icon);
popupMenu.add(menu);
return new SubPopupMenuActionsBuilder(menu);
}
代码示例来源:origin: nu.zoom/filechooser
private void createJMenu() {
log.trace("Creating new JMenu with name: " + menuName);
menu = new JMenu(menuName);
if (icon != null) {
log.trace("Setting menu icon to " + icon);
menu.setIcon(icon);
}
menu.add(new ClearAction(messages));
menu.add(new JSeparator(JSeparator.HORIZONTAL));
}
代码示例来源:origin: nu.zoom.desktop/filechooser
private void createJMenu(final String menuName, final Icon icon,
final String clearName, final String clearTooltip) {
log.trace("Creating new JMenu with name: " + menuName);
this.menu = new JMenu(menuName);
if (icon != null) {
log.trace("Setting menu icon to " + icon);
this.menu.setIcon(icon);
}
if (clearName != null) {
this.menu.add(new ClearAction(clearName, clearTooltip));
this.menu.add(new JSeparator(JSeparator.HORIZONTAL));
}
}
代码示例来源:origin: chatty/chatty
protected void setSubMenuIcon(String name, ImageIcon icon) {
getSubmenu(name, -1).setIcon(icon);
}
代码示例来源:origin: org.protege/protege-editor-owl
private void markCheckedMenu(boolean marked) {
if (marked) {
JCheckBoxMenuItem it = new JCheckBoxMenuItem();
it.setSelected(true);
/*
* This is unfortunate. We cannot easily get the checkbox
* icon from the L&F. Actually we get it, and then it
* throws a class cast exception when it tries to paint it,
* because it expects the component to be a JCheckBox.
*/
menu.setIcon(Icons.getIcon("hierarchy.collapsed.gif"));
} else {
menu.setIcon(null);
}
}
代码示例来源:origin: protegeproject/protege
private void markCheckedMenu(boolean marked) {
if (marked) {
JCheckBoxMenuItem it = new JCheckBoxMenuItem();
it.setSelected(true);
/*
* This is unfortunate. We cannot easily get the checkbox
* icon from the L&F. Actually we get it, and then it
* throws a class cast exception when it tries to paint it,
* because it expects the component to be a JCheckBox.
*/
menu.setIcon(Icons.getIcon("hierarchy.collapsed.gif"));
} else {
menu.setIcon(null);
}
}
代码示例来源:origin: edu.stanford.protege/org.protege.editor.owl
private void markCheckedMenu(boolean marked) {
if (marked) {
JCheckBoxMenuItem it = new JCheckBoxMenuItem();
it.setSelected(true);
/*
* This is unfortunate. We cannot easily get the checkbox
* icon from the L&F. Actually we get it, and then it
* throws a class cast exception when it tries to paint it,
* because it expects the component to be a JCheckBox.
*/
menu.setIcon(Icons.getIcon("hierarchy.collapsed.gif"));
} else {
menu.setIcon(null);
}
}
代码示例来源:origin: edu.stanford.protege/protege-editor-owl
private void markCheckedMenu(boolean marked) {
if (marked) {
JCheckBoxMenuItem it = new JCheckBoxMenuItem();
it.setSelected(true);
/*
* This is unfortunate. We cannot easily get the checkbox
* icon from the L&F. Actually we get it, and then it
* throws a class cast exception when it tries to paint it,
* because it expects the component to be a JCheckBox.
*/
menu.setIcon(Icons.getIcon("hierarchy.collapsed.gif"));
} else {
menu.setIcon(null);
}
}
代码示例来源:origin: Baralga/baralga
/**
* This method initializes importMenu.
* @return javax.swing.JMenu
*/
private JMenu getImportMenu() {
if (importMenu == null) {
importMenu = new JMenu();
importMenu.setIcon(new ImageIcon(MainFrame.class.getResource("/icons/import-menu.png"))); //$NON-NLS-1$
importMenu.setText(textBundle.textFor("MainFrame.ImportMenu.Title")); //$NON-NLS-1$
importMenu.setMnemonic(textBundle.textFor("MainFrame.ImportMenu.Title").charAt(0)); //$NON-NLS-1$
importMenu.add(getImportItem());
}
return importMenu;
}
代码示例来源:origin: net.sf.taverna.t2.ui-impl/workbench-impl
private void addPerspectiveToVisibilityMenu(final PerspectiveSPI perspective) {
JMenu perspectivemenu = new JMenu(perspective.getText()
+ " perspective");
perspectivemenu.setIcon(perspective.getButtonIcon());
final JMenuItem toggle = new JMenuItem();
toggle.setAction(new HideShowAction(perspective.isVisible() ? "Hide"
: "Show", perspective));
perspectivemenu.add(toggle);
perspectives.get(perspective).setVisible(perspective.isVisible());
perspectiveVisibilityMenu.add(perspectivemenu);
perspectiveVisibilityMap.put(perspective, perspectivemenu);
}
代码示例来源:origin: nu.zoom/portunis
/**
* Start was called. This is the start-stuff that needs to be on the AWT
* event queue.
*/
private void startOnEventQueue() {
JMenu keyStoreMenu = new JMenu(messages.getMessage("keystore.menu"));
keyStoreMenu.add(new LoadKeyStoreAction(workbench, this, messages));
loadedKeyStoreMenu = new JMenu(messages
.getMessage("keystore.load.loaded"));
loadedKeyStoreMenu.setEnabled(false);
loadedKeyStoreMenu.setIcon(Utils.getIconFromMessages(messages,
"keystore.load.loaded.icon"));
keyStoreMenu.add(loadedKeyStoreMenu);
workbench.getMenuBar().addMenu(KEYSTORE_MENU_KEY, keyStoreMenu);
}
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
protected JMenu createOpenRecentFileMenu(@Nullable View view) {
JMenuItem mi;
JMenu m;
m = new JMenu();
labels.configureMenu(m, //
(getAction(view, LoadFileAction.ID) != null || //
getAction(view, LoadDirectoryAction.ID) != null) ?//
"file.loadRecent" ://
"file.openRecent"//
);
m.setIcon(null);
m.add(getAction(view, ClearRecentFilesMenuAction.ID));
new OpenRecentMenuHandler(m, view);
return m;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-project-jsf
public JMenuItem getMenuPresenter () {
JMenu mainItem = new JMenuPlus();
Mnemonics.setLocalizedText(mainItem, getName());
mainItem.setIcon (SystemAction.get(ImportAction.class).getIcon());
HelpCtx.setHelpIDString (mainItem, ImportAction.class.getName());
mainItem.addMenuListener(new MainItemListener());
return mainItem;
}
代码示例来源:origin: freeplane/freeplane
private JMenu getSubmenu( final IconGroup group) {
final JMenu menu = new JMenu("\u25ba") {
private static final long serialVersionUID = 1L;
@Override
protected Point getPopupMenuOrigin() {
return new Point(getWidth(), 0);
}
};
menu.setFont(ARROW_FONT);
menu.setMargin(ICON_SUBMENU_INSETS);
menu.setIcon(group.getGroupIcon().getIcon());
for (final MindIcon icon : group.getIcons()) {
addActionToIconSubmenu(menu, icon, icon.getFileName());
}
menu.setToolTipText(group.getDescription());
return menu;
}
内容来源于网络,如有侵权,请联系作者删除!