當前位置: 首頁>>代碼示例>>Java>>正文


Java JMenuItem.doClick方法代碼示例

本文整理匯總了Java中javax.swing.JMenuItem.doClick方法的典型用法代碼示例。如果您正苦於以下問題:Java JMenuItem.doClick方法的具體用法?Java JMenuItem.doClick怎麽用?Java JMenuItem.doClick使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JMenuItem的用法示例。


在下文中一共展示了JMenuItem.doClick方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ok

import javax.swing.JMenuItem; //導入方法依賴的package包/類
private void ok() {
	DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
	if (node == null) {
		return;
	}
	else if ( mapApp != null && ((XML_Menu)node.getUserObject()).command != null ) {
		XML_Menu menu = (XML_Menu) node.getUserObject();
		JMenuItem mi = XML_Menu.getMenuItem(menu);

		if (mi != null)
			mi.doClick();
		else {
			XML_Menu.createMenuItem(menu).doClick();
		}
	}
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:17,代碼來源:SearchTree.java

示例2: testMenuPushIsNotified

import javax.swing.JMenuItem; //導入方法依賴的package包/類
public void testMenuPushIsNotified() throws Exception {
       TestSupport.ChangeableLookup lookup = new TestSupport.ChangeableLookup();
       TestLSA tlsa = new TestLSA( lookup );
assertTrue ("TestLSA action is enabled.", tlsa.isEnabled ());
tlsa.refreshCounter = 0;
       TestPropertyChangeListener tpcl = new TestPropertyChangeListener();
       tlsa.addPropertyChangeListener( tpcl );
       lookup.change(d2);
       assertEquals( "Refresh should be called once", 1, tlsa.refreshCounter );
       assertEquals( "One event should be fired", 1, tpcl.getEvents().size() );
       assertTrue("Action is enabled", tlsa.isEnabled());

       tlsa.setDisplayName("Jarda");
    
       
       JMenuItem item = new JMenuItem(tlsa);
       item.doClick();
       
       assertEquals("One record logged:\n" + my.recs, 1, my.recs.size());
       LogRecord r = my.recs.get(0);
       assertEquals("Menu push", "UI_ACTION_BUTTON_PRESS", r.getMessage());
       assertEquals("four args", 5, r.getParameters().length);
       assertEquals("first is the menu item", item, r.getParameters()[0]);
       assertEquals("second is its class", JMenuItem.class.getName(), r.getParameters()[1]);
       assertEquals("3rd is action", tlsa, r.getParameters()[2]);
       assertEquals("4th its class", tlsa.getClass().getName(), r.getParameters()[3]);
       assertEquals("5th name", "Jarda", r.getParameters()[4]);
       
       tlsa.clear();
       tpcl.clear();
       lookup.change(d3);
       assertEquals( "Refresh should be called once", 1, tlsa.refreshCounter );
       assertEquals( "One event should be fired", 1, tpcl.getEvents().size() );        
   }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:35,代碼來源:LookupSensitiveActionUILogTest.java


注:本文中的javax.swing.JMenuItem.doClick方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。