本文整理汇总了Python中javax.swing.JMenuItem.setMnemonic方法的典型用法代码示例。如果您正苦于以下问题:Python JMenuItem.setMnemonic方法的具体用法?Python JMenuItem.setMnemonic怎么用?Python JMenuItem.setMnemonic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JMenuItem
的用法示例。
在下文中一共展示了JMenuItem.setMnemonic方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DisplayStreetTable
# 需要导入模块: from javax.swing import JMenuItem [as 别名]
# 或者: from javax.swing.JMenuItem import setMnemonic [as 别名]
def DisplayStreetTable (collection):
columns=list(
(
("Name","name"),
)
)
tm= ObjectTableModel(collection,columns)
frame = MyFrame("Street Table")
frame.setSize(800, 1200)
frame.setLayout(BorderLayout())
table = JTable(tm)
table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS)
header = table.getTableHeader()
header.setUpdateTableInRealTime(True)
header.setReorderingAllowed(True);
scrollPane = JScrollPane()
scrollPane.getViewport().setView((table))
# copyButton = JButton('Merge') #,actionPerformed=self.noAction
# frame.add(copyButton)
listener=MyListener(table)
table.addMouseListener(listener)
table.addKeyListener(listener)
menubar = JMenuBar()
file = JMenu("Edit")
file.setMnemonic(KeyEvent.VK_E)
lookup = JMenuItem("Lookup",actionPerformed=frame.LookupEvent)
lookup.setMnemonic(KeyEvent.VK_L)
file.add(lookup)
menubar.add(file)
frame.setJMenuBar(menubar)
frame.add(scrollPane)
frame.pack();
frame.setSize(frame.getPreferredSize());
frame.show()
示例2: createItems
# 需要导入模块: from javax.swing import JMenuItem [as 别名]
# 或者: from javax.swing.JMenuItem import setMnemonic [as 别名]
def createItems(self, menuItems):
items = []
#Refer to MenuView's menuItems dictionary where each menu item has an
#array of two elements, the first is the key event and the second is the
#action asigned to the menu item
def getMethod(name):
return menuItems[name][1]
def getKeyEvent(name):
return menuItems[name][0]
for name, keyEvent in menuItems.items():
item = JMenuItem(name, actionPerformed =
getattr(self.menuView.controller, getMethod(name)))
item.setMnemonic(getKeyEvent(name))
items.append(item)
return items
示例3: createAction
# 需要导入模块: from javax.swing import JMenuItem [as 别名]
# 或者: from javax.swing.JMenuItem import setMnemonic [as 别名]
def createAction(callback, name, description=None, menu=None, mnemonic=None, accelerator=None, toolBar=None, menuItemType="standard"):
action = CallbackAction(callback, name, description)
if menu:
if menuItemType == "standard":
menuItem = JMenuItem(action)
elif menuItemType == "checkbox":
menuItem = JCheckBoxMenuItem(action)
elif menuItemType == "radiobutton":
menuItem = JRadioButtonMenuItem(action)
else:
internal_error("unsupported menu item type %s" % `menuItemType`)
menuItem = JMenuItem(action)
if mnemonic:
menuItem.setMnemonic(mnemonic)
if accelerator:
menuItem.setAccelerator(KeyStroke.getKeyStroke(ord(accelerator), Event.CTRL_MASK, 0))
menu.add(menuItem)
action.setMenuItem(menuItem)
if toolBar:
toolbarButton = JButton(action)
toolBar.add(toolbarButton)
return action