本文整理匯總了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();
}
}
}
示例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() );
}