本文整理匯總了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