Example usage for java.awt MenuItem setName

List of usage examples for java.awt MenuItem setName

Introduction

In this page you can find the example usage for java.awt MenuItem setName.

Prototype

public void setName(String name) 

Source Link

Document

Sets the name of the component to the specified string.

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  w  w  w .j  a  va  2  s .  c o m
 * @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);
    }
}