本文整理汇总了Java中javax.swing.JMenu.addNotify方法的典型用法代码示例。如果您正苦于以下问题:Java JMenu.addNotify方法的具体用法?Java JMenu.addNotify怎么用?Java JMenu.addNotify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JMenu
的用法示例。
在下文中一共展示了JMenu.addNotify方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPopupTextIsTaken
import javax.swing.JMenu; //导入方法依赖的package包/类
public void testPopupTextIsTaken() throws Exception {
Action action = new ActionsTest.TestAction();
JMenuItem item = new JMenuItem();
JMenu jmenu = new JMenu();
jmenu.addNotify();
assertTrue("Peer created", jmenu.isDisplayable());
jmenu.getPopupMenu().addNotify();
assertTrue("Peer for popup", jmenu.getPopupMenu().isDisplayable());
action.putValue("popupText", "&Ahoj");
action.putValue("menuText", "&Ble");
action.putValue(action.NAME, "&Mle");
Actions.connect(item, action, true);
assertEquals(Utilities.isMac() ? 0 : 'A', item.getMnemonic());
assertEquals("Ahoj", item.getText());
}
示例2: testMenuTextIsTaken
import javax.swing.JMenu; //导入方法依赖的package包/类
public void testMenuTextIsTaken() throws Exception {
Action action = new ActionsTest.TestAction();
JMenuItem item = new JMenuItem();
JMenu jmenu = new JMenu();
jmenu.addNotify();
assertTrue("Peer created", jmenu.isDisplayable());
jmenu.getPopupMenu().addNotify();
assertTrue("Peer for popup", jmenu.getPopupMenu().isDisplayable());
//action.putValue("popupText", "&Ahoj");
action.putValue("menuText", "&Ble");
action.putValue(action.NAME, "&Mle");
Actions.connect(item, action, false);
assertEquals(Utilities.isMac() ? 0 : 'B', item.getMnemonic());
assertEquals("Ble", item.getText());
}
示例3: testActionNameIsTaken
import javax.swing.JMenu; //导入方法依赖的package包/类
public void testActionNameIsTaken() throws Exception {
Action action = new ActionsTest.TestAction();
JMenuItem item = new JMenuItem();
JMenu jmenu = new JMenu();
jmenu.addNotify();
assertTrue("Peer created", jmenu.isDisplayable());
jmenu.getPopupMenu().addNotify();
assertTrue("Peer for popup", jmenu.getPopupMenu().isDisplayable());
//action.putValue("popupText", "&Ahoj");
//action.putValue("menuText", "&Ble");
action.putValue(action.NAME, "&Mle");
Actions.connect(item, action, false);
assertEquals(Utilities.isMac() ? 0 : 'M', item.getMnemonic());
assertEquals("Mle", item.getText());
}
示例4: doTestRefreshAfterBeingHidden
import javax.swing.JMenu; //导入方法依赖的package包/类
private void doTestRefreshAfterBeingHidden(boolean clone, boolean menu) throws IOException {
InstanceContent ic = new InstanceContent();
Lookup context = new AbstractLookup(ic);
Action instance;
if (clone) {
Action a = create(Lookup.EMPTY);
instance = ((ContextAwareAction)a).createContextAwareInstance(context);
} else {
instance = create(context);
}
if (!(instance instanceof Presenter.Popup)) {
// cannot test, skipping
return;
}
CharSequence log1 = Log.enable("org.netbeans.modules.project.ui.actions", Level.FINER);
assertFalse("Disabled", instance.isEnabled());
if (!log1.toString().contains("Refreshing")) {
fail("Should be refreshing: " + log1);
}
JMenuItem item = item(instance, menu);
JMenu jmenu = new JMenu();
jmenu.addNotify();
assertTrue("Peer created", jmenu.isDisplayable());
jmenu.getPopupMenu().addNotify();
assertTrue("Peer for popup", jmenu.getPopupMenu().isDisplayable());
item.addPropertyChangeListener(this);
jmenu.add(item);
assertEquals("anncessor properly changes, this means the actions framework is activated", 1, ancEvent);
assertFalse("Not enabled", item.isEnabled());
FileObject pfo = TestSupport.createTestProject(FileUtil.createMemoryFileSystem().getRoot(), "yaya");
FileObject pf2 = TestSupport.createTestProject(FileUtil.createMemoryFileSystem().getRoot(), "blabla");
MockServices.setServices(TestSupport.TestProjectFactory.class);
Project p = ProjectManager.getDefault().findProject(pfo);
Project p2 = ProjectManager.getDefault().findProject(pf2);
if (p instanceof TestSupport.TestProject) {
enhanceProject((TestSupport.TestProject)p);
}
if (p2 instanceof TestSupport.TestProject) {
enhanceProject((TestSupport.TestProject)p2);
}
assertNotNull("Project found", p);
assertNotNull("Project2 found", p2);
OpenProjects.getDefault().open(new Project[] { p }, false);
ic.add(p);
assertTrue("enabled", item.isEnabled());
assertEquals("One change", 1, change);
if (menu) {
item.removeNotify();
CharSequence log2 = Log.enable("org.netbeans.modules.project.ui.actions", Level.FINER);
ic.remove(p);
ic.add(p2);
if (log2.length() > 0) {
fail("Nothing shall happen:\n" + log2);
}
} // irrelevant for popups
}