当前位置: 首页>>代码示例>>Java>>正文


Java JMenu.addNotify方法代码示例

本文整理汇总了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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ActionsTest.java

示例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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ActionsTest.java

示例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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ActionsTest.java

示例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
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:68,代码来源:LookupSensitiveActionBase.java


注:本文中的javax.swing.JMenu.addNotify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。