當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。