Java Code Examples for java.awt.Menu#getItemCount()

The following examples show how to use java.awt.Menu#getItemCount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CMenu.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void setEnabled(final boolean b) {
    super.setEnabled(b);
    final Menu target = (Menu) getTarget();
    final int count = target.getItemCount();
    for (int i = 0; i < count; ++i) {
        MenuItem item = target.getItem(i);
        MenuItemPeer p = (MenuItemPeer) LWCToolkit.targetToPeer(item);
        if (p != null) {
            p.setEnabled(b && item.isEnabled());
        }
    }
}
 
Example 2
Source File: CMenu.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void setEnabled(final boolean b) {
    super.setEnabled(b);
    final Menu target = (Menu) getTarget();
    final int count = target.getItemCount();
    for (int i = 0; i < count; ++i) {
        MenuItem item = target.getItem(i);
        MenuItemPeer p = (MenuItemPeer) LWCToolkit.targetToPeer(item);
        if (p != null) {
            p.setEnabled(b && item.isEnabled());
        }
    }
}
 
Example 3
Source File: CMenu.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void setEnabled(final boolean b) {
    super.setEnabled(b);
    final Menu target = (Menu) getTarget();
    final int count = target.getItemCount();
    for (int i = 0; i < count; ++i) {
        MenuItem item = target.getItem(i);
        MenuItemPeer p = (MenuItemPeer) LWCToolkit.targetToPeer(item);
        if (p != null) {
            p.setEnabled(b && item.isEnabled());
        }
    }
}
 
Example 4
Source File: CMenu.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void setEnabled(final boolean b) {
    super.setEnabled(b);
    final Menu target = (Menu) getTarget();
    final int count = target.getItemCount();
    for (int i = 0; i < count; ++i) {
        MenuItem item = target.getItem(i);
        MenuItemPeer p = (MenuItemPeer) LWCToolkit.targetToPeer(item);
        if (p != null) {
            p.setEnabled(b && item.isEnabled());
        }
    }
}
 
Example 5
Source File: CMenu.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void setEnabled(final boolean b) {
    super.setEnabled(b);
    final Menu target = (Menu) getTarget();
    final int count = target.getItemCount();
    for (int i = 0; i < count; ++i) {
        MenuItem item = target.getItem(i);
        MenuItemPeer p = (MenuItemPeer) LWCToolkit.targetToPeer(item);
        if (p != null) {
            p.setEnabled(b && item.isEnabled());
        }
    }
}
 
Example 6
Source File: CMenu.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void setEnabled(final boolean b) {
    super.setEnabled(b);
    final Menu target = (Menu) getTarget();
    final int count = target.getItemCount();
    for (int i = 0; i < count; ++i) {
        MenuItem item = target.getItem(i);
        MenuItemPeer p = (MenuItemPeer) LWCToolkit.targetToPeer(item);
        if (p != null) {
            p.setEnabled(b && item.isEnabled());
        }
    }
}
 
Example 7
Source File: CMenu.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public final void setEnabled(final boolean b) {
    super.setEnabled(b);
    final Menu target = (Menu) getTarget();
    final int count = target.getItemCount();
    for (int i = 0; i < count; ++i) {
        MenuItem item = target.getItem(i);
        MenuItemPeer p = (MenuItemPeer) LWCToolkit.targetToPeer(item);
        if (p != null) {
            p.setEnabled(b && item.isEnabled());
        }
    }
}
 
Example 8
Source File: Utils.java    From Scripts with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the index of the MenuItem labeled by the specified string.
 *
 * @param menu
 *            the java.awt.Menu to be parsed
 * @param label
 *            the java.awt.MenuItem label being searched
 * @return the index of the java.awt.MenuItem. Returns {@code -1} if no
 *         match is found, {@code null} if menu is not available.
 */
private Integer getMenuItem(final Menu menu, final String label) {
	int position = -1;
	if (menu == null) {
		return null;
	}
	for (int i = 0; i < menu.getItemCount(); i++) {
		if (menu.getItem(i).getLabel().equals(label)) {
			position = i;
			break;
		}
	}
	return position;
}
 
Example 9
Source File: Utils.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
static private void restoreMenu(final Menu menu) {
	final int n_menuitems = menu.getItemCount();
	for (int i=0; i<n_menuitems; i++) {
		final MenuItem menu_item = menu.getItem(i);
		if (menu_item instanceof Menu) {
			restoreMenu((Menu)menu_item);
		}
		menu_item.setEnabled(true);
	}
}