Example usage for javax.swing JMenuItem setIcon

List of usage examples for javax.swing JMenuItem setIcon

Introduction

In this page you can find the example usage for javax.swing JMenuItem setIcon.

Prototype

@BeanProperty(visualUpdate = true, description = "The button's default icon")
public void setIcon(Icon defaultIcon) 

Source Link

Document

Sets the button's default icon.

Usage

From source file:net.java.sip.communicator.impl.osdependent.jdic.TrayMenuFactory.java

/**
 * Changes the tray menu item properties, like name, text and icon.
 * @param trayItem the tray menu item to change
 * @param name the new name of the item//from www.j av a 2  s .com
 * @param textID the new text identifier
 * @param iconID the new icon string identifier
 */
private static void changeTrayMenuItem(Object trayItem, String name, String textID, String iconID) {
    String text = Resources.getString(textID);

    if (trayItem instanceof JMenuItem) {
        JMenuItem jmenuItem = (JMenuItem) trayItem;
        jmenuItem.setName(name);
        jmenuItem.setText(text);
        jmenuItem.setIcon(Resources.getImage(iconID));
    } else if (trayItem instanceof MenuItem) {
        MenuItem menuItem = (MenuItem) trayItem;
        menuItem.setName(name);
        menuItem.setLabel(text);
    }
}

From source file:grafix.telas.componentes.GrafixChartMouseListener.java

private void criarPopupMenu() {
    popup = new JPopupMenu();
    JMenuItem menuItem;

    menuItem = new JMenuItem("Configurar janela...");
    menuItem.setIcon(new javax.swing.ImageIcon(ConfiguracoesGrafix.PASTA_ICONES + "config.gif"));
    menuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            abrirFormConfiguracoes(-1);/*from w  w  w.j a va 2  s . c  o  m*/
        }
    });
    popup.add(menuItem);

    menuItem = new JMenuItem("Configurar grfico...");
    menuItem.setIcon(new javax.swing.ImageIcon(ConfiguracoesGrafix.PASTA_ICONES + "configurar3.gif"));
    menuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            abrirFormConfiguracoes(plotClicado);
        }
    });
    popup.add(menuItem);

    menuItem = new JMenuItem("ndices...");
    menuItem.setIcon(new javax.swing.ImageIcon(ConfiguracoesGrafix.PASTA_ICONES + "indices.gif"));
    menuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            abrirFormIndices(plotClicado);
        }
    });
    popup.add(menuItem);
}

From source file:ec.nbdemetra.sa.revisionanalysis.RevisionAnalysisChart.java

private JMenu newExportMenu() {
    DemetraUI demetraUI = DemetraUI.getDefault();

    JMenu result = new JMenu("Export image to");
    result.setIcon(demetraUI.getPopupMenuIcon(FontAwesome.FA_FLOPPY_O));

    JMenuItem copy = new ActionMenuItem(ChartCommand.copyImage().toAction(chartPanel));
    copy.setIcon(demetraUI.getPopupMenuIcon(FontAwesome.FA_CLIPBOARD));
    copy.setText("Clipboard");

    JMenuItem file = new ActionMenuItem(ChartCommand.saveImage().toAction(chartPanel));
    file.setIcon(demetraUI.getPopupMenuIcon(FontAwesome.FA_PICTURE_O));
    file.setText("File...");

    result.add(copy);/*w w  w.  j  a va 2s.com*/
    result.add(file);

    return result;
}

From source file:fi.smaa.jsmaa.gui.SMAA2GUIFactory.java

private JMenuItem createAddOrdinalCriterionItem() {
    JMenuItem ordCrit = new JMenuItem("Ordinal");
    ordCrit.setIcon(ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_ORDINALCRITERION));

    ordCrit.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            addCriterionAndStartRename(new OrdinalCriterion(generateNextCriterionName()));
        }/*from w w w  .  j  a  va  2 s.  co m*/
    });
    return ordCrit;
}

From source file:fi.smaa.jsmaa.gui.SMAA2GUIFactory.java

private JMenuItem createAddScaleCriterionItem() {
    JMenuItem cardCrit = new JMenuItem("Cardinal");
    cardCrit.setIcon(ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_CARDINALCRITERION));

    cardCrit.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            addCriterionAndStartRename(new ScaleCriterion(generateNextCriterionName()));
        }/*from   w  w w.  ja  v  a  2  s  .  c om*/
    });
    return cardCrit;
}

From source file:MenuDemo.java

protected JMenuBar createMenuBar() {
    final JMenuBar menuBar = new JMenuBar();

    JMenu menuFile = new JMenu("File");
    menuFile.setMnemonic('f');

    JMenuItem menuItem = new JMenuItem("New");
    menuItem.setIcon(new ImageIcon("file_new.gif"));
    menuItem.setMnemonic('n');
    ActionListener lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("New");
        }/* w w w. j a  va  2  s  . c  o  m*/
    };
    menuItem.addActionListener(lst);
    menuFile.add(menuItem);

    menuItem = new JMenuItem("Open...");
    menuItem.setIcon(new ImageIcon("file_open.gif"));
    menuItem.setMnemonic('o');
    lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            MenuDemo.this.repaint();
            if (fileChooser.showOpenDialog(MenuDemo.this) != JFileChooser.APPROVE_OPTION)
                return;
            System.out.println(fileChooser.getSelectedFile());
        }
    };
    menuItem.addActionListener(lst);
    menuFile.add(menuItem);

    menuItem = new JMenuItem("Save...");
    menuItem.setIcon(new ImageIcon("file_save.gif"));
    menuItem.setMnemonic('s');
    lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("Save...");
        }
    };
    menuItem.addActionListener(lst);
    menuFile.add(menuItem);

    menuFile.addSeparator();

    menuItem = new JMenuItem("Exit");
    menuItem.setMnemonic('x');
    lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    };
    menuItem.addActionListener(lst);
    menuFile.add(menuItem);
    menuBar.add(menuFile);

    ActionListener fontListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateMonitor();
        }
    };

    JMenu mFont = new JMenu("Font");
    mFont.setMnemonic('o');

    ButtonGroup group = new ButtonGroup();
    menus = new JMenuItem[FontNames.length];
    for (int i = 0; i < FontNames.length; i++) {
        int m = i + 1;
        menus[i] = new JRadioButtonMenuItem(m + " " + FontNames[i]);
        boolean selected = (i == 0);
        menus[i].setSelected(selected);
        menus[i].setMnemonic('1' + i);
        menus[i].setFont(fontArray[i]);
        menus[i].addActionListener(fontListener);
        group.add(menus[i]);
        mFont.add(menus[i]);
    }

    mFont.addSeparator();

    boldMenuItem = new JCheckBoxMenuItem("Bold");
    boldMenuItem.setMnemonic('b');
    Font fn = fontArray[1].deriveFont(Font.BOLD);
    boldMenuItem.setFont(fn);
    boldMenuItem.setSelected(false);
    boldMenuItem.addActionListener(fontListener);
    mFont.add(boldMenuItem);

    italicMenuItem = new JCheckBoxMenuItem("Italic");
    italicMenuItem.setMnemonic('i');
    fn = fontArray[1].deriveFont(Font.ITALIC);
    italicMenuItem.setFont(fn);
    italicMenuItem.setSelected(false);
    italicMenuItem.addActionListener(fontListener);
    mFont.add(italicMenuItem);

    menuBar.add(mFont);

    return menuBar;
}

From source file:ec.nbdemetra.chainlinking.outlineview.ChainLinkingChart.java

private JMenu newExportMenu() {
    DemetraUI demetraUI = DemetraUI.getDefault();

    JMenu rslt = new JMenu("Export image to");
    rslt.setIcon(demetraUI.getPopupMenuIcon(FontAwesome.FA_FLOPPY_O));

    JMenuItem copy = new ActionMenuItem(ChartCommand.copyImage().toAction(chartPanel));
    copy.setText("Clipboard...");
    copy.setIcon(demetraUI.getPopupMenuIcon(FontAwesome.FA_CLIPBOARD));

    JMenuItem file = new ActionMenuItem(ChartCommand.saveImage().toAction(chartPanel));
    file.setText("File...");
    file.setIcon(demetraUI.getPopupMenuIcon(FontAwesome.FA_PICTURE_O));

    rslt.add(copy);/*w w  w  .  j a v  a 2s. c  om*/
    rslt.add(file);

    return rslt;
}

From source file:fi.smaa.jsmaa.gui.SMAATRIGUIFactory.java

@Override
protected JMenuItem buildAddCriterionItem() {
    JMenuItem item = new JMenuItem("Add new");
    item.setIcon(ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_ADDCRITERION));
    item.addActionListener(new AddOutrankingCriterionAction());
    return item;//from   www  .  j  a v  a2  s  . co  m
}

From source file:de.peterspan.csv2db.AppWindow.java

private void initialize() {
    frame = new JFrame();

    frame.setIconImage(Icons.IC_APPLICATION_X_LARGE.getImage());

    AppWindow._frame = frame;//from  w ww  . j a  va2 s . com
    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            if (reallyExit() == JOptionPane.YES_OPTION) {
                SingleInstance.release();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            }
        }
    });

    frame.setTitle(Messages.getString("AppWindow.0") + " " + Messages.getString("AppWindow.version.code")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    frame.setLocationRelativeTo(null);
    JMenuBar menuBar = new JMenuBar();
    frame.setJMenuBar(menuBar);

    JMenu mnFile = new JMenu(Messages.getString("AppWindow.1")); //$NON-NLS-1$
    menuBar.add(mnFile);

    JMenuItem mntmExit = new JMenuItem(Messages.getString("AppWindow.3")); //$NON-NLS-1$
    mntmExit.setIcon(Icons.IC_LOGOUT_SMALL);
    mntmExit.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            WindowEvent wev = new WindowEvent(frame, WindowEvent.WINDOW_CLOSING);
            Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(wev);

        }
    });
    mnFile.add(mntmExit);

    JMenu mnEdit = new JMenu(Messages.getString("AppWindow.4")); //$NON-NLS-1$
    menuBar.add(mnEdit);

    JMenuItem mntmOptions = new JMenuItem(Messages.getString("AppWindow.5")); //$NON-NLS-1$
    mntmOptions.setIcon(Icons.IC_PREFERENCES_SYSTEM_SMALL);
    mntmOptions.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            //            new OptionsDialog(frame);
        }
    });
    mnEdit.add(mntmOptions);

    JMenu mnHelp = new JMenu(Messages.getString("AppWindow.6")); //$NON-NLS-1$
    menuBar.add(mnHelp);

    JMenuItem mntmAbout = new JMenuItem(Messages.getString("AppWindow.7")); //$NON-NLS-1$
    mntmAbout.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            try {
                new AboutDialog(frame);
            } catch (URISyntaxException e) {
                // TODO Auto-generated catch block

                e.printStackTrace();
            }
        }
    });
    mnHelp.add(mntmAbout);

    createContent();

    DialogUtil.getInstance().setMainFrame(frame);

}

From source file:fi.smaa.jsmaa.gui.SMAATRIGUIFactory.java

private JMenuItem createAddCatMenuItem() {
    JMenuItem item = new JMenuItem("Add new");
    item.setMnemonic('n');
    item.setIcon(ImageFactory.IMAGELOADER.getIcon(FileNames.ICON_ADD));
    item.addActionListener(new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            addCategory();/*w w w .  j a v  a2  s  . c  om*/
        }
    });
    return item;
}