Example usage for javax.swing JMenuItem getName

List of usage examples for javax.swing JMenuItem getName

Introduction

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

Prototype

public String getName() 

Source Link

Document

Gets the name of the component.

Usage

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

/**
 * Handles the <tt>ActionEvent</tt> when one of the menu items is selected.
 *
 * @param evt the event containing the menu item name
 *//*from  w w w.ja  v a  2 s. c o m*/
private static void actionPerformed(ActionEvent evt) {
    Object source = evt.getSource();
    String itemName;
    if (source instanceof JMenuItem) {
        JMenuItem menuItem = (JMenuItem) source;
        itemName = menuItem.getName();
    } else {
        MenuItem menuItem = (MenuItem) source;
        itemName = menuItem.getName();
    }

    if (itemName.equals("settings")) {
        OsDependentActivator.getUIService().getConfigurationContainer().setVisible(true);
    } else if (itemName.equals("service.gui.QUIT")) {
        OsDependentActivator.getShutdownService().beginShutdown();
    } else if (itemName.equals("addContact")) {
        ExportedWindow dialog = OsDependentActivator.getUIService()
                .getExportedWindow(ExportedWindow.ADD_CONTACT_WINDOW);

        if (dialog != null)
            dialog.setVisible(true);
        else
            OsDependentActivator.getUIService().getPopupDialog().showMessagePopupDialog(
                    Resources.getString("impl.systray.FAILED_TO_OPEN_ADD_CONTACT_DIALOG"));
    } else if (itemName.equals("service.gui.SHOW")) {
        OsDependentActivator.getUIService().setVisible(true);
        OsDependentActivator.getUIService().bringToFront();

        changeTrayMenuItem(source, "service.gui.HIDE", "service.gui.HIDE",
                "service.gui.icons.SEARCH_ICON_16x16");
    } else if (itemName.equals("service.gui.HIDE")) {
        OsDependentActivator.getUIService().setVisible(false);

        changeTrayMenuItem(source, "service.gui.SHOW", "service.gui.SHOW",
                "service.gui.icons.SEARCH_ICON_16x16");
    }
}

From source file:it.cnr.icar.eric.client.ui.swing.metal.MetalThemeMenu.java

/**
 * Updates the UI strings based on the current locale.
 */// ww  w  .ja  va 2 s.  c om
protected void updateText() {
    for (int i = 0; i < getItemCount(); i++) {
        JMenuItem item = getItem(i);

        // item is null if there is a JSeparator at that position.
        if (item != null) {
            String itemName = item.getName();
            String themeName;

            try {
                themeName = themeNames.getString(itemName);
            } catch (MissingResourceException mre) {
                themeName = itemName;

                Object[] noResourceArgs = { itemName, getLocale() };
                MessageFormat form = new MessageFormat(themeNames.getString("message.error.noResource"));
                log.error(form.format(noResourceArgs));
            }

            item.setText(themeName);
        }
    }
}

From source file:org.gcaldaemon.gui.ConfigEditor.java

public final void actionPerformed(ActionEvent evt) {

    // Common actions
    Object source = evt.getSource();
    if (source == null) {
        return;/*from w w w .  j  a v  a 2s  . co  m*/
    }
    if (source == exitMenu) {
        exit();
        return;
    }
    if (source == saveMenu) {
        save();
        return;
    }
    if (source == logMenu) {
        status(Messages.getString("log.viewer")); //$NON-NLS-1$
        new LogDialog(this, config);
        return;
    }
    if (source == transMenu) {
        status(Messages.getString("translate")); //$NON-NLS-1$
        TranslatorDialog translator = new TranslatorDialog(this);
        String code = translator.getSelectedLanguage();
        if (code != null) {
            setLanguage(code);
        }
        return;
    }
    if (source == aboutMenu) {
        info(Messages.getString("about"), Messages.getString("config.editor") + " - " + Configurator.VERSION); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        return;
    }
    if (source instanceof JMenuItem) {
        JMenuItem item = (JMenuItem) source;
        String param = item.getName();
        if (param != null && param.length() > 1) {
            if (param.charAt(0) == '!') {
                param = param.substring(1);
                int i = param.indexOf('[');
                if (i > 0) {
                    param = param.substring(0, i).trim();
                }
                setLanguage(param);
            } else {
                status(item.getText());
                setLookAndFeel(param.substring(1));
                SwingUtilities.updateComponentTreeUI(this);
            }
        }
    }
}

From source file:uk.nhs.cfh.dsp.srth.desktop.uiframework.utils.ActionComponentManager.java

/**
 * Reset quit menu menu item./*from   w  w w  .j av  a2 s  .c  om*/
 */
private synchronized void resetQuitMenuMenuItem() {
    // get file menu
    JMenu fileMenu = getMenuWithName("File");
    int itemCount = fileMenu.getItemCount();
    for (int i = 0; i < itemCount; i++) {
        JMenuItem item = fileMenu.getItem(i);
        if ("exitMenuItem".equals(item.getName())) {
            // reset item to last item
            fileMenu.insert(item, itemCount);
        }
    }
}