本文整理汇总了Python中javax.swing.JMenuItem类的典型用法代码示例。如果您正苦于以下问题:Python JMenuItem类的具体用法?Python JMenuItem怎么用?Python JMenuItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JMenuItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createMenuItems
def createMenuItems(self, invocation):
def addRequestsToTab(e):
for messageInfo in messages:
# saveBuffers is required since modifying the original from its source changes the saved objects, its not a copy
messageIndex = self._db.createNewMessage(self._callbacks.saveBuffersToTempFiles(messageInfo),
self._helpers.analyzeRequest(messageInfo).getUrl())
#self._messageTable.getModel().addRow(row)
self._messageTable.redrawTable()
ret = []
messages = invocation.getSelectedMessages()
# Check if the messages in the target tree have a response
valid = True
if invocation.getInvocationContext() == invocation.CONTEXT_TARGET_SITE_MAP_TREE:
for selected in messages:
if not selected.getResponse():
valid = False
if valid:
menuItem = JMenuItem("Send request(s) to AuthMatrix");
menuItem.addActionListener(addRequestsToTab)
ret.append(menuItem)
return ret
示例2: initTabs
def initTabs(self):
#
## init autorize tabs
#
self.logTable = Table(self)
self.logTable.setAutoCreateRowSorter(True)
tableWidth = self.logTable.getPreferredSize().width
self.logTable.getColumn("ID").setPreferredWidth(Math.round(tableWidth / 50 * 2))
self.logTable.getColumn("URL").setPreferredWidth(Math.round(tableWidth / 50 * 24))
self.logTable.getColumn("Orig. Length").setPreferredWidth(Math.round(tableWidth / 50 * 4))
self.logTable.getColumn("Modif. Length").setPreferredWidth(Math.round(tableWidth / 50 * 4))
self.logTable.getColumn("Unauth. Length").setPreferredWidth(Math.round(tableWidth / 50 * 4))
self.logTable.getColumn("Authorization Enforcement Status").setPreferredWidth(Math.round(tableWidth / 50 * 4))
self.logTable.getColumn("Authorization Unauth. Status").setPreferredWidth(Math.round(tableWidth / 50 * 4))
self._splitpane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT)
self._splitpane.setResizeWeight(1)
self.scrollPane = JScrollPane(self.logTable)
self._splitpane.setLeftComponent(self.scrollPane)
self.scrollPane.getVerticalScrollBar().addAdjustmentListener(autoScrollListener(self))
self.menuES0 = JCheckBoxMenuItem(self._enfocementStatuses[0],True)
self.menuES1 = JCheckBoxMenuItem(self._enfocementStatuses[1],True)
self.menuES2 = JCheckBoxMenuItem(self._enfocementStatuses[2],True)
self.menuES0.addItemListener(menuTableFilter(self))
self.menuES1.addItemListener(menuTableFilter(self))
self.menuES2.addItemListener(menuTableFilter(self))
copyURLitem = JMenuItem("Copy URL");
copyURLitem.addActionListener(copySelectedURL(self))
self.menu = JPopupMenu("Popup")
self.menu.add(copyURLitem)
self.menu.add(self.menuES0)
self.menu.add(self.menuES1)
self.menu.add(self.menuES2)
self.tabs = JTabbedPane()
self._requestViewer = self._callbacks.createMessageEditor(self, False)
self._responseViewer = self._callbacks.createMessageEditor(self, False)
self._originalrequestViewer = self._callbacks.createMessageEditor(self, False)
self._originalresponseViewer = self._callbacks.createMessageEditor(self, False)
self._unauthorizedrequestViewer = self._callbacks.createMessageEditor(self, False)
self._unauthorizedresponseViewer = self._callbacks.createMessageEditor(self, False)
self.tabs.addTab("Modified Request", self._requestViewer.getComponent())
self.tabs.addTab("Modified Response", self._responseViewer.getComponent())
self.tabs.addTab("Original Request", self._originalrequestViewer.getComponent())
self.tabs.addTab("Original Response", self._originalresponseViewer.getComponent())
self.tabs.addTab("Unauthenticated Request", self._unauthorizedrequestViewer.getComponent())
self.tabs.addTab("Unauthenticated Response", self._unauthorizedresponseViewer.getComponent())
self.tabs.addTab("Configuration", self.pnl)
self.tabs.setSelectedIndex(6)
self._splitpane.setRightComponent(self.tabs)
示例3: createMenuItems
def createMenuItems(self, invocation):
if invocation.getInvocationContext() != invocation.CONTEXT_MESSAGE_EDITOR_REQUEST:
return None
menuItem = JMenuItem("Evaluate Groovy")
menuItem.addActionListener(
GroovyActionListener(invocation.getSelectedMessages()[0], invocation.getSelectionBounds()))
return [menuItem]
示例4: init
def init(self):
w, h, aa, threads = (512, 512, 1, 2)
canvas = RayTracePanel(w, h, aa, threads)
self.getContentPane().add(JScrollPane(canvas))
# Save FileChooser
# fcS = JFileChooser()
# fcS.addChoosableFileFilter(FileNameExtensionFilter('Windows Bitmap (*.bmp)', ['bmp']))
# fcS.addChoosableFileFilter(FileNameExtensionFilter('JPEG / JFIF (*.jpg)', ['jpg']))
# fcS.addChoosableFileFilter(FileNameExtensionFilter('Portable Network Graphics (*.png)', ['png']))
# def saveFile(event):
# '''Performed when the save button is pressed'''
# result = fcS.showSaveDialog(frame)
# if result == JFileChooser.APPROVE_OPTION:
# file = fcS.getSelectedFile()
# fname = file.getPath()
# ext = fcS.getFileFilter().getExtensions()[0]
# if not fname.endswith('.' + ext):
# file = File(fname + '.' + ext)
# canvas.saveToFile(file, ext)
# Open FileChooser
# fcO = JFileChooser()
# fcO.addChoosableFileFilter(FileNameExtensionFilter('RayTrace Scene File (*.rts)', ['rts']))
# def openFile(event):
# '''Performed when the open button is pressed'''
# result = fcO.showOpenDialog(frame)
# if result == JFileChooser.APPROVE_OPTION:
# fname = fcO.getSelectedFile().getPath()
# if fname.endswith('.rts'):
# f = open(fname, 'rb')
# newScene = SceneFactory().buildScene(f)
# f.close()
# Painter(canvas, newScene, openButton, saveButton, stopButton).start()
def stop(event):
"""Peformed when the stop button is pressed"""
canvas.stopRendering()
# Setup Menu
menuBar = JMenuBar()
menu = JMenu("File")
menuBar.add(menu)
# openButton = JMenuItem("Open...", actionPerformed=openFile)
# openButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK))
# menu.add(openButton)
# saveButton = JMenuItem("Save as...", actionPerformed=saveFile)
# saveButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK))
# menu.add(saveButton)
menu.addSeparator()
stopButton = JMenuItem("Stop Render", actionPerformed=stop)
stopButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0))
stopButton.setEnabled(False)
menu.add(stopButton)
menu.addSeparator()
# closeButton = JMenuItem('Close', actionPerformed=exit)
# closeButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK))
# menu.add(closeButton)
self.setJMenuBar(menuBar)
示例5: addAction
def addAction(self, action, mnemonic= -1, shortcut=None):
item = JMenuItem(action.toSwingAction())
if shortcut is not None:
item.accelerator = shortcut
if mnemonic != -1:
item.mnemonic = mnemonic
self.applyStyle(item)
self.menu.add(item)
示例6: createMenuItems
def createMenuItems(self, invocation):
responses = invocation.getSelectedMessages();
if responses > 0:
ret = LinkedList()
requestMenuItem = JMenuItem("Send to PT Manager");
requestMenuItem.addActionListener(handleMenuItems(self,responses[0], "request"))
ret.add(requestMenuItem);
return(ret);
return null;
示例7: add_check_item
def add_check_item(self, tool, view, check, viewMenu):
checkItem = JMenuItem(check.title)
if check.icon is not None:
checkItem.setIcon(check.icon)
checkItem.addActionListener(QatMenuActionListener(self.app,
"check",
tool,
view,
check))
viewMenu.add(checkItem)
示例8: initTabs
def initTabs(self):
#
## init autorize tabs
#
self._splitpane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT)
self.scrollPane = JScrollPane(self.logTable)
self._splitpane.setLeftComponent(self.scrollPane)
colorsMenu = JMenu("Paint")
redMenu = JMenuItem("Red")
noneMenu = JMenuItem("None")
greenMenu = JMenuItem("Green")
redMenu.addActionListener(paintChange(self, "Red"))
noneMenu.addActionListener(paintChange(self, None))
greenMenu.addActionListener(paintChange(self, "Green"))
colorsMenu.add(redMenu)
colorsMenu.add(noneMenu)
colorsMenu.add(greenMenu)
self.menu = JPopupMenu("Popup")
self.menu.add(colorsMenu)
self.tabs = JTabbedPane()
self.tabs.addTab("Request", self._requestViewer.getComponent())
self.tabs.addTab("Response", self._responseViewer.getComponent())
self.tabs.addTab("Vulnerability", self.pnl)
self.tabs.addTab("Project Settings", self.projectSettings)
self.tabs.setSelectedIndex(2)
self._splitpane.setRightComponent(self.tabs)
示例9: tcMenu
def tcMenu():
caseSubMenu = JMenu("case view")
for pkg in (entity == 'package'):
pkgSubMenu = JMenu(pkg.name)
cases = [ x.getNode2() for x in (pkg->(entity == 'testcase'))]
for case in cases:
caseItem = JMenuItem(case.name)
caseItem.actionPerformed = lambda event : viewCase(event.getActionCommand())
pkgSubMenu.add(caseItem)
caseSubMenu.add(pkgSubMenu)
return caseSubMenu
示例10: generate_menu_items
def generate_menu_items(self):
for k in self.items:
#print k + '\n'
#menuitem = JMenuItem(k, actionPerformed=self.menuItemClicked)
menuitem = JMenuItem(k)
#menu.append(JMenuItem(self._actionName, None , actionPerformed= lambda x, inv=invocation: self.sqlMapScan(inv)))
menuitem.addActionListener(ActionHandler(self._callbacks, k, self._helers))
self.menuitems[menuitem] = k
示例11: createMenuItems
def createMenuItems(self, invocation):
menus = []
messages = invocation.getSelectedMessages()
if messages:
items = self.interpreter.getLocals().get('items', [])
context = 'Assign' if not items else 'Append'
menu = JMenuItem("%s to local variable items in Console" % (context, ))
menu.addActionListener(AssignLocalsActionListener(self, 'items', messages))
menus.append(menu)
return menus
示例12: initMenu
def initMenu():
global glzz
tmenu = JMenu("testQ")
smellv = JMenuItem("smell view")
smellv.actionPerformed = lambda event : SmellView(glzz).go()
tmenu.add(smellv)
radialv = JMenuItem("radial suite view")
radialv.actionPerformed = lambda event : RadialSuiteView(glzz).go()
tmenu.add(radialv)
treesv = JMenuItem("tree suite view")
# treesv.actionPerformed = lambda event : displayTreeSuiteView(glzz)
treesv.actionPerformed = lambda event : TreeSuiteView(glzz).go()
tmenu.add(treesv)
tmenu.add(tcMenu())
smellp = JMenuItem("smell pie")
smellp.actionPerformed = lambda event : plotSmellFrequency()
tmenu.add(smellp)
gbar = Guess.getMainUIWindow().getGMenuBar()
gbar.add(tmenu)
gbar.getMenu(3).removeAll() # deface the layout menu
gbar.revalidate()
gbar.repaint()
示例13: createMenuItems
def createMenuItems(self, invocation):
messages = invocation.getSelectedMessages()
def addRequestsToTab(e):
for messageInfo in messages:
# saveBuffers is required since modifying the original from its source changes the saved objects, its not a copy
messageIndex = self._db.createNewMessage(self._callbacks.saveBuffersToTempFiles(messageInfo),
self._helpers.analyzeRequest(messageInfo).getUrl())
#self._messageTable.getModel().addRow(row)
self._messageTable.redrawTable()
ret = []
menuItem = JMenuItem("Send request(s) to AuthMatrix");
menuItem.addActionListener(addRequestsToTab)
ret.append(menuItem)
return(ret)
示例14: DisplayStreetTable
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()
示例15: __init__
def __init__(self):
self.fMap = { IRequestInfo.CONTENT_TYPE_URL_ENCODED : self.handleURLEncoded,
IRequestInfo.CONTENT_TYPE_JSON : self.handleJSON,
IRequestInfo.CONTENT_TYPE_XML: self.handleXML,
IRequestInfo.CONTENT_TYPE_NONE : self.handleNone,
IRequestInfo.CONTENT_TYPE_UNKNOWN : self.handleNone }
self.menuItem = JMenuItem('curlit')
self.menuItem.addActionListener(self)