Java Utililty Methods JMenuItem

List of utility methods to do JMenuItem

Description

The list of methods to do JMenuItem are organized into topic(s).

Method

voidabout(JMenuItem anItem)
public static void invalidPath() { JOptionPane.showMessageDialog(null, "No se puede salvar un juego dentro de la carpeta " + "'levels'.\nVuelve a intentarlo.", "Error!", JOptionPane.ERROR_MESSAGE); }
anItem.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent event) {
        JOptionPane.showMessageDialog(null,
                "Trabajo Practico especial\nProgramacion " + "Orientada a Objetos.\n\nDaniel Lobo - "
                        + "Teresa C. Di Tada - Felipe Martinez\n      "
                        + "                            2012",
                "About Sokoban", JOptionPane.INFORMATION_MESSAGE);
...
voidaddIntoMenu(JMenu menu, JMenuItem[] menuItems)
Adds JMenuItems into specified JMenu.
for (int i = 0; i < menuItems.length; i++) {
    menu.add(menuItems[i]);
voidaddMenu(JMenu poMenuPadre, JMenuItem poElemento, int piPosicion)
add un menbu al menu padre en la posicion correspondiente, si piPosicion es negativo lo inserta por el final
int liLongitud = poMenuPadre.getMenuComponentCount();
int liPosSeparador = -1;
if (piPosicion < 0) {
    poMenuPadre.insert(poElemento, (liPosSeparador != -1 ? liPosSeparador : liLongitud) + piPosicion);
} else {
    poMenuPadre.insert(poElemento, (liPosSeparador != -1 ? liPosSeparador : 0) + piPosicion);
JMenuItemaddMenuItem(final JMenuItem mi, final C topLevelMenu, final List path)
add Menu Item
if (path.size() == 0 || path.size() % 2 == 0)
    throw new IllegalArgumentException("Path should be of the form group/menu/group/... : " + path);
JComponent menu = topLevelMenu;
for (int i = 0; i < path.size() - 1; i += 2) {
    final String groupName = path.get(i);
    final String menuName = path.get(i + 1);
    menu = addChild(menu, groupName, new JMenu(menuName), JMenu.class, false);
final String actionGroupName = path.get(path.size() - 1);
return addChild(menu, actionGroupName, mi, JMenuItem.class, true);
voidaplicarMenu(JMenuItem loMenuO, JMenuItem loMenuD)
aplicar Menu
loMenuD.setText(loMenuO.getText());
loMenuD.setIcon(loMenuO.getIcon());
loMenuD.setMnemonic(loMenuO.getMnemonic());
loMenuD.setVisible(loMenuO.isVisible());
ActionListener[] lo = loMenuO.getListeners(ActionListener.class);
ActionListener[] loD = loMenuD.getListeners(ActionListener.class);
for (int i = 0; i < loD.length; i++) {
    loMenuD.removeActionListener(loD[i]);
...
voidapplyDefaultProperties(final JMenuItem comp)
Sets default background and foreground color as well as a default font for the specified component.
if (comp == null) {
    return;
applyProperties(comp, "MenuItem.background", 
        "MenuItem.foreground", 
        "MenuItem.font"); 
voidattachAcceleratorKeyNoCtrl(JMenuItem item, int keyEvent)
attach Accelerator Key No Ctrl
item.setAccelerator(KeyStroke.getKeyStroke(keyEvent, 0));
JMenuItemcloneMenuItem(final JMenuItem item)
Creates a copy of this menu item, whose contents update automatically whenever the original menu item changes.
if (item == null)
    return null;
JMenuItem jmi;
if (item instanceof JMenu) {
    final JMenu menu = (JMenu) item;
    final JMenu jm = new JMenu();
    final int count = menu.getItemCount();
    for (int i = 0; i < count; i++) {
...
voidconfigureMenuItem(JMenuItem item, Action action)
configure Menu Item
KeyStroke keystroke = (KeyStroke) action.getValue(Action.ACCELERATOR_KEY);
if (keystroke != null) {
    item.setAccelerator(keystroke);
item.setIcon(null);
item.setToolTipText(null);
JMenuItemcreateJMenuItem(Action action)
Creates a menu item from specified action.
JMenuItem item = new JMenuItem(action);
item.setActionCommand((String) action.getValue(Action.ACTION_COMMAND_KEY));
return item;