本文整理汇总了Java中javax.swing.JMenu.getMenuComponents方法的典型用法代码示例。如果您正苦于以下问题:Java JMenu.getMenuComponents方法的具体用法?Java JMenu.getMenuComponents怎么用?Java JMenu.getMenuComponents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JMenu
的用法示例。
在下文中一共展示了JMenu.getMenuComponents方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: synchMenuPresenters
import javax.swing.JMenu; //导入方法依赖的package包/类
@Override
public JComponent[] synchMenuPresenters(JComponent[] items) {
JComponent[] comps = new JComponent[1];
for (JComponent item : items) {
if (item instanceof Actions.MenuItem) {
comps[0] = item;
// update menu items to reflect Action.isEnabled
((Actions.MenuItem) item).synchMenuPresenters(comps);
} else if(item instanceof JMenu) {
JMenu jMenu = (JMenu) item;
for (Component subItem : jMenu.getMenuComponents()) {
if (subItem instanceof Actions.MenuItem) {
comps[0] = (JComponent) subItem;
// update menu items to reflect Action.isEnabled
((Actions.MenuItem) subItem).synchMenuPresenters(comps);
}
}
}
}
// returns most up-to date items
return createMenuItems();
}
示例2: doTestInAwt
import javax.swing.JMenu; //导入方法依赖的package包/类
final void doTestInAwt() {
assertEquals("One menu", 1, mb.getMenuCount());
JMenu m = mb.getMenu(0);
assertEquals("named file", "File", m.getText());
long before = System.currentTimeMillis();
MenuBarTest.simulateExpansionOfMenu(m);
Component[] arr = m.getMenuComponents();
assertEquals("One menu item", 1, arr.length);
long after = System.currentTimeMillis();
long took = after - before;
if (took > 5000) {
fail("Too long time to compute menu items (" + took + " ms), probably time out somewhere!");
}
}
示例3: addItemToSubMenu
import javax.swing.JMenu; //导入方法依赖的package包/类
/**
*
* @param topLevelName
* @param subMenuName
* @param tooltip
* @param enabled
*/
public void addItemToSubMenu(JMenuItem item, String topLevelName,
String subMenuName, String tooltip, boolean enabled) {
JMenu topLevel = (JMenu) parentMenus.get(topLevelName);
if (topLevel != null) {
Component[] components = topLevel.getMenuComponents();
for (int i=0 ; i<components.length ; i++) {
if (components[i] instanceof JMenu) {
JMenu subMenu = (JMenu) components[i];
if (subMenu.getText().equals(subMenuName)) {
item.setToolTipText(tooltip);
subMenu.add(item);
}
}
}
}
}
示例4: configureMenu
import javax.swing.JMenu; //导入方法依赖的package包/类
void configureMenu(final JComponent parent, final JMenu menu) {
// make sure it will draw it's border so we can have rollovers and selection
menu.setBorderPainted(true);
//install the wrapper icon if not a toplevel JMenu
if(!isTopLevelMenu(menu)) {
if(!(menu.getIcon() instanceof WrapperIcon)) {
menu.setIcon(new WrapperIcon(menu.getIcon()));
}
}
// configure the maps and popups
JPopupMenu popup = menu.getPopupMenu();
menuPopupUIMap.put(menu, popup.getUI());
popup.setUI(new VisualDesignerPopupMenuUI(this, popup.getUI()));
// get all of the components in this menu
Component[] subComps = menu.getMenuComponents();
// if this isn't the first time this menu has been opened then the sub components
// will have been moved to the popupPanel already, so we will find them there instead.
JPanel popupPanel = getPopupFactory().containerMap.get(menu);
if(popupPanel != null) {
subComps = popupPanel.getComponents();
}
RADVisualContainer menuRAD = (RADVisualContainer) formDesigner.getMetaComponent(menu);
registerForm(menuRAD,menu);
// recurse for sub-menus
for(Component c : subComps) {
if(c instanceof JMenu) {
configureMenu(menu, (JMenu)c);
RADComponent rad = formDesigner.getMetaComponent(c);
registerForm((RADVisualContainer)rad,(JMenu)c);
} else {
configureMenuItem(menu, (JComponent) c);
}
}
}
示例5: getMenuComponents
import javax.swing.JMenu; //导入方法依赖的package包/类
private List<JMenuItem> getMenuComponents(JMenu AMenu) {
Component[] components = AMenu.getMenuComponents();
List<JMenuItem> items = new ArrayList<JMenuItem>();
for (int j = 0; j < components.length; j++) {
if (!(components[j] instanceof AbstractButton)) {
continue;
}
items.add((JMenuItem) components[j]);
}
return items;
}
示例6: createVerifyMenu
import javax.swing.JMenu; //导入方法依赖的package包/类
/**
* Creates and returns a verification menu for the menu bar.
*/
private JMenu createVerifyMenu() {
JMenu result = new JMenu(Options.VERIFY_MENU_NAME);
result.setMnemonic(Options.VERIFY_MENU_MNEMONIC);
result.add(this.actions.getCheckCTLAction(true));
result.add(this.actions.getCheckCTLAction(false));
result.addSeparator();
JMenu mcScenarioMenu = new ModelCheckingMenu(this);
for (Component menuComponent : mcScenarioMenu.getMenuComponents()) {
result.add(menuComponent);
}
return result;
}
示例7: getPopupMenu
import javax.swing.JMenu; //导入方法依赖的package包/类
public @Override JPopupMenu getPopupMenu(){
JPopupMenu pm = super.getPopupMenu();
pm.removeAll();
boolean enable = false;
BaseKit bKit = getKit();
if (bKit==null) bKit = BaseKit.getKit(NbEditorKit.class);
if (bKit!=null){
Action action = bKit.getActionByName(NbEditorKit.generateFoldPopupAction);
if (action instanceof BaseAction) {
JTextComponent component = NbCodeFoldingAction.getComponent();
MimePath mimePath = component == null ? MimePath.EMPTY : MimePath.parse(DocumentUtilities.getMimeType(component));
Preferences prefs = MimeLookup.getLookup(mimePath).lookup(Preferences.class);
boolean foldingAvailable = prefs.getBoolean(SimpleValueNames.CODE_FOLDING_ENABLE, EditorPreferencesDefaults.defaultCodeFoldingEnable);
if (foldingAvailable){
ActionMap contextActionmap = org.openide.util.Utilities.actionsGlobalContext().lookup(ActionMap.class);
if (contextActionmap!=null){
foldingAvailable = contextActionmap.get(BaseKit.collapseFoldAction) != null &&
component != null;
if (!foldingAvailable){
bKit = BaseKit.getKit(NbEditorKit.class);
if (bKit!=null){
Action defaultAction = bKit.getActionByName(NbEditorKit.generateFoldPopupAction);
if (defaultAction instanceof BaseAction) action = defaultAction;
}
}
}
}
JMenu menu = (JMenu)((BaseAction)action).getPopupMenuItem(foldingAvailable ? component : null);
if (menu!=null){
Component comps[] = menu.getMenuComponents();
for (int i=0; i<comps.length; i++){
pm.add(comps[i]);
if (comps[i].isEnabled() && !(comps[i] instanceof JSeparator)) {
enable = true;
}
}
}
}
}
setEnabled(enable);
pm.pack();
return pm;
}