本文整理汇总了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() );
}