def run(self): frame = JFrame('Table11', size=(300, 170), locationRelativeTo=None, defaultCloseOperation=JFrame.EXIT_ON_CLOSE) menuBar = JMenuBar() resize = JMenu('AUTO_RESIZE') bGroup = ButtonGroup() for name, value in self.info: rb = JRadioButtonMenuItem(name, actionPerformed=self.handler, selected=(name == 'Rest')) bGroup.add(rb) resize.add(rb) menuBar.add(resize) frame.setJMenuBar(menuBar) headings = 'T/F,Date,Integer,Float,Double'.split(',') model = myTM(self.data, headings) self.table = table = JTable( model, selectionMode=ListSelectionModel.SINGLE_SELECTION) table.getColumnModel().getColumn(model.getColumnCount() - 1 # i.e., last column ).setCellRenderer(myRenderer()) setColumnWidths(table) frame.add(JScrollPane(table)) frame.setVisible(1)
def MenuBar(self): #----------------------------------------------------------------------- # Start by creating our application menubar #----------------------------------------------------------------------- menu = JMenuBar() #----------------------------------------------------------------------- # "File" entry #----------------------------------------------------------------------- jmFile = JMenu('File') jmiExit = JMenuItem('Exit', actionPerformed=self.Exit) jmFile.add(jmiExit) menu.add(jmFile) #----------------------------------------------------------------------- # "Help" entry #----------------------------------------------------------------------- jmHelp = JMenu('Help') jmiAbout = JMenuItem('About', actionPerformed=self.about) jmiNote = JMenuItem('Notice', actionPerformed=self.notice) jmHelp.add(jmiAbout) jmHelp.add(jmiNote) menu.add(jmHelp) return menu
def createMenuItems(self, invocation): self.menus = [] self.mainMenu = JMenu("fakeIp") self.menus.append(self.mainMenu) self.invocation = invocation # print invocation.getSelectedMessages()[0].getRequest() menuItem = ['inputIP', '127.0.0.1', 'randomIP', '0x2130706433'] for tool in menuItem: # self.mainMenu.add(JMenuItem(tool)) if tool == 'inputIP': menu = JMenuItem( tool, None, actionPerformed=lambda x: self.modifyHeader(x)) self.mainMenu.add(menu) elif tool == '127.0.0.1': menu = JMenuItem( tool, None, actionPerformed=lambda x: self.modifyHeader(x)) self.mainMenu.add(menu) elif tool == 'randomIP': menu = JMenuItem( tool, None, actionPerformed=lambda x: self.modifyHeader(x)) self.mainMenu.add(menu) elif tool == '0x2130706433': menu = JMenuItem( tool, None, actionPerformed=lambda x: self.modifyHeader(x)) self.mainMenu.add(menu) return self.menus if self.menus else None
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)
def createMenuItems(self, contextMenuInvocation): menuItemList = ArrayList() self._contextMenuData = contextMenuInvocation.getSelectedMessages() submenu = JMenu(EXTENSION_NAME) for menuitem in sorted(self.menuitems): submenu.add(menuitem) menuItemList.add(submenu) return menuItemList
def loadMenus(self): self.menus = [] self.mainMenu = JMenu("TPLogScan") self.menus.append(self.mainMenu) menu = JMenuItem('ThinkPHP v3', None, actionPerformed=lambda x: self.eventHandler(x)) self.mainMenu.add(menu) menu = JMenuItem('ThinkPHP v5', None, actionPerformed=lambda x: self.eventHandler(x)) self.mainMenu.add(menu)
def createMenuItems(self, invocation): menu = JMenu(self._actionName) self._menu_item = JMenuItem( "Export", None, actionPerformed=lambda x, inv=invocation: self.Action(inv), ) menu.add(self._menu_item) return [menu]
def _prepare_menu(self, labels, parent): for label in sorted(labels.keys()): if labels[label]: menu_item = JMenu(label) self._prepare_menu(labels[label], menu_item) else: menu_item = JMenuItem(label) menu_item.addActionListener(self) parent.add(menu_item)
def buildJESFunctionsMenu(action): menuSections = [] for (section, api_functions) in JES_API_SECTIONS: newMenuSection = JMenu(str(section), actionPerformed=action) for api_function in api_functions: newMenuItem = JMenuItem(api_function, actionPerformed=action) newMenuSection.add(newMenuItem) menuSections.append(newMenuSection) return menuSections
def __init__(self): self.running = True menuBar = JMenuBar() menu = JMenu("File") menu.add(OpenAction(self)) menu.add(CloseAction(self)) menu.addSeparator() menu.add(QuitAction(self)) self.addWindowListener(ProfelisWindowAdapter(self)) menuBar.add(menu) self.setJMenuBar(menuBar) self.contentPane = JPanel() self.contentPane.layout = GridBagLayout() constraints = GridBagConstraints() self.blastLocation = JTextField( System.getProperty("user.home") + "/blast") self.databaseLocation = JTextField( System.getProperty("user.home") + "/blast/db") self.projects = JTabbedPane() constraints.gridx, constraints.gridy = 0, 0 constraints.gridwidth, constraints.gridheight = 1, 1 constraints.fill = GridBagConstraints.NONE constraints.weightx, constraints.weighty = 0, 0 self.contentPane.add(JLabel("Blast Location"), constraints) constraints.gridx, constraints.gridy = 1, 0 constraints.fill = GridBagConstraints.HORIZONTAL constraints.weightx, constraints.weighty = 1, 0 self.contentPane.add(self.blastLocation, constraints) constraints.gridx, constraints.gridy = 2, 0 constraints.fill = GridBagConstraints.NONE constraints.weightx, constraints.weighty = 0, 0 self.contentPane.add(JButton(BlastAction(self)), constraints) constraints.gridx, constraints.gridy = 3, 0 constraints.fill = GridBagConstraints.NONE constraints.weightx, constraints.weighty = 0, 0 self.contentPane.add(JLabel("Database Location"), constraints) constraints.gridx, constraints.gridy = 4, 0 constraints.fill = GridBagConstraints.HORIZONTAL constraints.weightx, constraints.weighty = 1, 0 self.contentPane.add(self.databaseLocation, constraints) constraints.gridx, constraints.gridy = 5, 0 constraints.fill = GridBagConstraints.NONE constraints.weightx, constraints.weighty = 0, 0 self.contentPane.add(JButton(DatabaseAction(self)), constraints) constraints.gridx, constraints.gridy = 0, 1 constraints.gridwidth, constraints.gridheight = 6, 1 constraints.fill = GridBagConstraints.BOTH constraints.weightx, constraints.weighty = 1, 1 self.contentPane.add(self.projects, constraints)
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)
def buildJavaAPIMenu(action): menuSections = [] for section in API_SECTIONS: newMenuSection = JMenu(str(section), actionPerformed=action) for api_function in getMethodList(section): func_name = str(section) + '.' + api_function newMenuItem = JMenuItem(func_name, actionPerformed=action) newMenuSection.add(newMenuItem) menuSections.append(newMenuSection) return menuSections
def createMenuItems(self, invocation): menu = JMenu(self._actionName) responses = invocation.getSelectedMessages() if len(responses) == 1: menu.add( JMenuItem( "CSRF", None, actionPerformed=lambda x, inv=invocation: self.Action(inv), )) return [menu]
def createMenuItems(self, invocation): global invocations invocations = invocation menuItemList = ArrayList() #self._contextMenuData = contextMenuInvocation.getSelectedMessages() submenu = JMenu(self._actionName) for menuitem in sorted(self.menuitems): submenu.add(menuitem) menuItemList.add(submenu) return menuItemList
def __init__(self, fileManager): self.fileManager = fileManager fileManager.onRead.connect(self.onReadOrWrite) fileManager.onWrite.connect(self.onReadOrWrite) self.files = self.retrieveList() self.menu = JMenu("Open Recent Program") self.menuActions = WeakValueDictionary() self.disabledItem = JMenuItem("(No recent programs)") self.disabledItem.enabled = False self.fillMenu()
def createMenuBar(self): menuBar = JMenuBar() fileMenu = JMenu('File') data = [['Spam', self.spam], ['Eggs', self.eggs], ['Bacon', self.bacon]] bGroup = ButtonGroup() for name, handler in data: rb = JRadioButtonMenuItem(name, actionPerformed=handler, selected=(name == 'Spam')) bGroup.add(rb) fileMenu.add(rb) exitItem = fileMenu.add(JMenuItem('Exit', actionPerformed=self.exit)) menuBar.add(fileMenu) helpMenu = JMenu('Help') aboutItem = helpMenu.add(JMenuItem('About', actionPerformed=self.about)) menuBar.add(helpMenu) return menuBar
def handleMouseEvent(self, event): if event.isPopupTrigger(): loadMenu = JMenuItem("Load .proto") loadMenu.addActionListener(self.tab.listener) popup = JPopupMenu() popup.add(loadMenu) if self.tab.descriptors: deserializeAsMenu = JMenu("Deserialize As...") popup.addSeparator() popup.add(deserializeAsMenu) for pb2, descriptors in self.tab.descriptors.iteritems(): subMenu = JMenu(pb2) deserializeAsMenu.add(subMenu) for name, descriptor in descriptors.iteritems(): protoMenu = JMenuItem(name) protoMenu.addActionListener( DeserializeProtoActionListener(self.tab, descriptor)) subMenu.add(protoMenu) popup.show(event.getComponent(), event.getX(), event.getY()) return
def menuBar( self ) : menu = JMenuBar() #----------------------------------------------------------------------- # "File" entry #----------------------------------------------------------------------- jmFile = JMenu( 'File' ) jmiExit = JMenuItem( 'Exit', actionPerformed = self.Exit ) jmFile.add( jmiExit ) menu.add( jmFile ) #----------------------------------------------------------------------- # "Help" entry #----------------------------------------------------------------------- jmHelp = JMenu( 'Help' ) jmiAbout = JMenuItem( 'About', actionPerformed = self.about ) jmiNote = JMenuItem( 'Notice', actionPerformed = self.notice ) jmHelp.add( jmiAbout ) jmHelp.add( jmiNote ) menu.add( jmHelp ) return menu
def createMenuItems(self, invoker): self.invoker = invoker self.selection = self.invoker.getSelectionBounds() context = self.invoker.getInvocationContext() if not (context == self.invoker.CONTEXT_MESSAGE_EDITOR_REQUEST or context == self.invoker.CONTEXT_MESSAGE_VIEWER_REQUEST or context == self.invoker.CONTEXT_MESSAGE_EDITOR_RESPONSE or context == self.invoker.CONTEXT_MESSAGE_VIEWER_RESPONSE ): return None menu_translate_sel = JMenuItem( self.src_menu_text, actionPerformed=self.translate) menu_translate_sel.setEnabled(False) menu_translate_clip = JMenuItem( self.dst_menu_text, actionPerformed=self.translate) menu_translate_clip.setEnabled(False) if self.selection is not None and self.selection[0] != self.selection[1]: menu_translate_sel.setEnabled(True) if self.get_clipboard_text() is not None: menu_translate_clip.setEnabled(True) menu_header = JMenuItem('%s v%s' % ( BurpExtender.extension_name, BurpExtender.extension_version)) menu_header.setEnabled(False) menu_src = JMenu(' - Source Language [%s]' % (self.src)) menu_dst = JMenu(' - Destination Language [%s]' % (self.dst)) menu_automatic = JCheckBoxMenuItem( 'Automatic', actionPerformed=self.select_src) menu_src.add(menu_automatic) if self.src == menu_automatic.getText(): menu_automatic.setSelected(True) for lang in sorted(langs): menu_item = JCheckBoxMenuItem( lang, actionPerformed=self.select_src) if lang == self.src: menu_item.setSelected(True) menu_src.add(menu_item) menu_item = JCheckBoxMenuItem( lang, actionPerformed=self.select_dst) if lang == self.dst: menu_item.setSelected(True) menu_dst.add(menu_item) return [menu_header, menu_src, menu_dst, menu_translate_sel, menu_translate_clip]
def menuBar(self): result = JMenuBar() newMenu = result.add(JMenu('New')) newMenu.add(JMenuItem('InnerFrame', actionPerformed=self.addIframe)) newMenu.addSeparator() newMenu.add(JMenuItem('Exit', actionPerformed=self.exit)) return result
def __init__(self): self.setAlwaysOnTop(False); self.setSize(500, 500); menubar = JMenuBar(); menu = JMenu("A Menu"); menu_ac = menu.getAccessibleContext(); menu_ac.setAccessibleDescription("The only menu in this program"); menuitem = JMenuItem("A Menu Item"); menu.add(menuitem); menubar.add(menu); self.setJMenuBar(menubar); lbl = JLabel("A Label"); lbl.setHorizontalAlignment(JLabel.CENTER); lbl.setVerticalAlignment(JLabel.CENTER); self.setContentPane(lbl); self.setVisible(True);
def __init__(self): self.running = True menuBar = JMenuBar() menu = JMenu("File") menu.add(OpenAction(self)) menu.add(CloseAction(self)) menu.addSeparator() menu.add(QuitAction(self)) self.addWindowListener(ProfelisWindowAdapter(self)) menuBar.add(menu) self.setJMenuBar(menuBar) self.contentPane = JPanel() self.contentPane.layout = GridBagLayout() constraints = GridBagConstraints() self.blastLocation = JTextField(System.getProperty("user.home") + "/blast") self.databaseLocation = JTextField(System.getProperty("user.home") + "/blast/db") self.projects = JTabbedPane() constraints.gridx, constraints.gridy = 0, 0 constraints.gridwidth, constraints.gridheight = 1, 1 constraints.fill = GridBagConstraints.NONE constraints.weightx, constraints.weighty = 0, 0 self.contentPane.add(JLabel("Blast Location"), constraints) constraints.gridx, constraints.gridy = 1, 0 constraints.fill = GridBagConstraints.HORIZONTAL constraints.weightx, constraints.weighty = 1, 0 self.contentPane.add(self.blastLocation, constraints) constraints.gridx, constraints.gridy = 2, 0 constraints.fill = GridBagConstraints.NONE constraints.weightx, constraints.weighty = 0, 0 self.contentPane.add(JButton(BlastAction(self)), constraints) constraints.gridx, constraints.gridy = 3, 0 constraints.fill = GridBagConstraints.NONE constraints.weightx, constraints.weighty = 0, 0 self.contentPane.add(JLabel("Database Location"), constraints) constraints.gridx, constraints.gridy = 4, 0 constraints.fill = GridBagConstraints.HORIZONTAL constraints.weightx, constraints.weighty = 1, 0 self.contentPane.add(self.databaseLocation, constraints) constraints.gridx, constraints.gridy = 5, 0 constraints.fill = GridBagConstraints.NONE constraints.weightx, constraints.weighty = 0, 0 self.contentPane.add(JButton(DatabaseAction(self)), constraints) constraints.gridx, constraints.gridy = 0, 1 constraints.gridwidth, constraints.gridheight = 6, 1 constraints.fill = GridBagConstraints.BOTH constraints.weightx, constraints.weighty = 1, 1 self.contentPane.add(self.projects, constraints)
class MenuBuilder(BaseMenuBuilder): def __init__(self, label, style=NengoStyle()): BaseMenuBuilder.__init__(self, style) self.menu = JMenu(label) self.isFirstSection = True if style is not None: self.applyStyle(self.menu, self.style) 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)
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()
def run(self): #----------------------------------------------------------------------- # Create and set up the window. #----------------------------------------------------------------------- frame = JFrame('GlassPaneDemo') frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) #----------------------------------------------------------------------- # Start creating and adding components. #----------------------------------------------------------------------- changeButton = JCheckBox('Glass pane "visible"') changeButton.setSelected(0) #----------------------------------------------------------------------- # Set up the content pane, where the 'main GUI' lives. #----------------------------------------------------------------------- contentPane = frame.getContentPane() contentPane.setLayout(FlowLayout()) contentPane.add(changeButton) contentPane.add(JButton('Button 1')) contentPane.add(JButton('Button 2')) #----------------------------------------------------------------------- # Set up the menu bar, which appears above the content pane. #----------------------------------------------------------------------- menuBar = JMenuBar() menu = JMenu('Menu') menu.add(JMenuItem('Do nothing')) menuBar.add(menu) frame.setJMenuBar(menuBar) #----------------------------------------------------------------------- # Set up the glass pane, which appears over both menu bar and # content pane and is an item listener on the change button #----------------------------------------------------------------------- myGlassPane = MyGlassPane(changeButton, menuBar, contentPane) changeButton.addItemListener(myGlassPane) frame.setGlassPane(myGlassPane) #----------------------------------------------------------------------- # Resize the frame to display the visible components contain therein, # and have the frame (application) make itself visisble. #----------------------------------------------------------------------- frame.pack() frame.setVisible(1)
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)
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
def makeMenu(self): menuBar = JMenuBar(background=Color.blue, foreground=Color.white) showMenu = JMenu('Show', background=Color.blue, foreground=Color.white) self.deprecated = JCheckBoxMenuItem('Deprecated', 1, actionPerformed=self.showItems) showMenu.add(self.deprecated) self.protected = JCheckBoxMenuItem('Protected', 1, actionPerformed=self.showItems) showMenu.add(self.protected) showMenu.addSeparator() showMenu.add(JMenuItem('Exit', actionPerformed=self.exit)) menuBar.add(showMenu) return menuBar
def createMenuItems(self, invocation): self._context = invocation menuList = ArrayList() parentMenu = JMenu('CorsPoc') menuItemWildCard = JMenuItem("WildCard", actionPerformed=self.asWildCard) menuItemBasicPoc = JMenuItem("BasicPoc", actionPerformed=self.asBasicPoc) menuItemnullOrigin = JMenuItem("nullOrigin", actionPerformed=self.asnullOrigin) parentMenu.add(menuItemWildCard) parentMenu.add(menuItemBasicPoc) parentMenu.add(menuItemnullOrigin) menuList.add(parentMenu) # Request info iRequestInfo = self._helpers.analyzeRequest( self._context.getSelectedMessages()[0]) self.url = iRequestInfo.getUrl().toString() self.payload = ''.join( map(chr, self._context.getSelectedMessages()[0].getRequest())).split( '\r\n\r\n')[1] return menuList
def run(self): frame = JFrame('Menu2', size=(200, 125), defaultCloseOperation=JFrame.EXIT_ON_CLOSE) menuBar = JMenuBar(background=Color.blue, foreground=Color.white) fileMenu = JMenu('File') fileMenu.add(JMenuItem('Exit')) menuBar.add(fileMenu) helpMenu = JMenu('Help') helpMenu.add(JMenuItem('About')) menuBar.add(helpMenu) frame.setJMenuBar(menuBar) frame.setVisible(1)
def createMenuItems(self, invocation): # 创建菜单右键菜单选项 self.context = invocation menu_list = JMenu('orz Plugin') if self.context.getToolFlag() == 0x40: menu_list.add( JMenuItem(u'添加IP伪造请求头', actionPerformed=self.update_client_src_ip)) menu_list.add( JMenuItem(u'生成DNSLog Payload', actionPerformed=self.dnslog_payload)) # DEBUG 按钮 menu_list.add( JMenuItem('orz - DEBUG', actionPerformed=self.debug_fun)) return [menu_list]
class RecentFiles(object): numberOfFiles = 8 separator = u";" def __init__(self, fileManager): self.fileManager = fileManager fileManager.onRead.connect(self.onReadOrWrite) fileManager.onWrite.connect(self.onReadOrWrite) self.files = self.retrieveList() self.menu = JMenu("Open Recent Program") self.menuActions = WeakValueDictionary() self.disabledItem = JMenuItem("(No recent programs)") self.disabledItem.enabled = False self.fillMenu() ### Maintaining the menu def onReadOrWrite(self, fileManager, filename, **_): try: self.files.remove(filename) except ValueError: if len(self.files) >= self.numberOfFiles: # Remove enough files that there's a spare slot. self.files = self.files[:self.numberOfFiles - 1] self.files.insert(0, filename) self.storeList(self.files) self.fillMenu() def fillMenu(self): self.menu.removeAll() if self.files: for filename in self.files: action = self.menuActions.get(filename) if action is None: action = PythonAction(self.fileManager.readAction, filename, name=filename) self.menuActions[filename] = action self.menu.add(action) else: self.menu.add(self.disabledItem) ### Writing filenames def retrieveList(self): joined = JESConfig.getInstance().getStringProperty(JESConfig.CONFIG_RECENT_FILES) if not joined: return [] else: return [fn for fn in joined.split(self.separator) if os.path.isfile(fn)] def storeList(self, files): joined = self.separator.join(files) JESConfig.getInstance().setStringProperty(JESConfig.CONFIG_RECENT_FILES, joined)
def createMenuItems(self, invocation): self.menus = [] self.mainMenu = JMenu("Xss-Sql-Fuzz") self.menus.append(self.mainMenu) self.invocation = invocation #print invocation.getSelectedMessages()[0].getRequest() menuItem = [ 'addXFF', 'addReferer', 'post fuzz1:x\'"><rivirtest>', 'post fuzz2:</script><img+src=0+onerror=alert(1)>', 'post fuzz3:\'-sleep(3)-\'', 'get fuzz1:x\'"><rivirtest>', 'get fuzz2:</script><img+src=0+onerror=alert(1)>', 'get fuzz3:\'-sleep(3)-\'' ] for tool in menuItem: #self.mainMenu.add(JMenuItem(tool)) if tool == 'addXFF': menu = JMenuItem( tool, None, actionPerformed=lambda x: self.modifyHeader(x)) self.mainMenu.add(menu) elif tool == 'addReferer': menu = JMenuItem( tool, None, actionPerformed=lambda x: self.modifyHeader(x)) self.mainMenu.add(menu) elif tool.startswith('post fuzz'): menu = JMenuItem(tool, None, actionPerformed=lambda x: self.postFuzz(x) ) # 不能传入invocation,x传入的是当前munuItem的上下文 self.mainMenu.add(menu) elif tool.startswith('get fuzz'): menu = JMenuItem(tool, None, actionPerformed=lambda x: self.getFuzz(x)) self.mainMenu.add(menu) return self.menus if self.menus else None
def run(self): frame = JFrame('Menu3', size=(200, 125), defaultCloseOperation=JFrame.EXIT_ON_CLOSE) menuBar = JMenuBar(background=Color.blue) # print '\nmenuBar size before:', menuBar.getPreferredSize() fileMenu = JMenu('File', foreground=Color.white) fileMenu.add(JMenuItem('Exit')) menuBar.add(fileMenu) # print 'menuBar size after:', menuBar.getPreferredSize() helpMenu = JMenu('Help', foreground=Color.white) helpMenu.add(JMenuItem('About')) menuBar.add(helpMenu) frame.setJMenuBar(menuBar) frame.setVisible(1)
def createMenuItems(self, invocation): # Do not create a menu item unless getting a context menu from the proxy history or scanner results is_intruder_results = invocation.getInvocationContext( ) == invocation.CONTEXT_INTRUDER_ATTACK_RESULTS is_proxy_history = invocation.getInvocationContext( ) == invocation.CONTEXT_PROXY_HISTORY is_scanner_results = invocation.getInvocationContext( ) == invocation.CONTEXT_SCANNER_RESULTS is_target_tree = invocation.getInvocationContext( ) == invocation.CONTEXT_TARGET_SITE_MAP_TREE is_correct_context = is_proxy_history or is_scanner_results or is_target_tree or is_intruder_results if not is_correct_context: return request_response = invocation.getSelectedMessages()[0] functionality = self.view.get_checklist()["Functionality"] # Create the menu item for the Burp context menu bugcatcher_menu = JMenu("Send to HUNT - Methodology") # TODO: Sort the functionality by name and by vuln class for functionality_name in functionality: tests = functionality[functionality_name]["tests"] menu_test = JMenu(functionality_name) # Create a menu item and an action listener per vulnerability # class on each functionality for test_name in tests: item_test = JMenuItem(test_name) menu_action_listener = MenuActionListener( self.view, self.callbacks, request_response, functionality_name, test_name) item_test.addActionListener(menu_action_listener) menu_test.add(item_test) bugcatcher_menu.add(menu_test) burp_menu = [] burp_menu.append(bugcatcher_menu) return burp_menu
def createMenuBar(self): menuBar = JMenuBar() fileMenu = JMenu('File') data = [['Spam', self.spam], ['Eggs', self.eggs], ['Bacon', self.bacon]] for name, handler in data: fileMenu.add(JCheckBoxMenuItem(name, actionPerformed=handler)) exitItem = fileMenu.add(JMenuItem('Exit', actionPerformed=self.exit)) menuBar.add(fileMenu) helpMenu = JMenu('Help') aboutItem = helpMenu.add(JMenuItem('About', actionPerformed=self.about)) menuBar.add(helpMenu) return menuBar
def __init__(self, view, name, infunc, outfunc, lfunc, inargs=(), outargs=(), largs=(), label=None): core.DataViewComponent.__init__(self, label) self.view = view self.name = name self.infunc = infunc self.outfunc = outfunc self.lfunc = lfunc self.in_neuron = 0 self.out_neuron = 0 self.indata = self.view.watcher.watch(name, infunc, args=inargs) self.outdata = self.view.watcher.watch(name, outfunc, args=outargs) self.ldata = self.view.watcher.watch(name, lfunc, args=largs) self.label_height = 10 self.border_top = 10 self.border_left = 30 self.border_right = 30 self.border_bottom = 20 self.setSize(300, 200) self.last_maxy = None self.neurons = len(self.outdata.get_first()) self.popup.add(JPopupMenu.Separator()) in_menu = JMenu("in neuron") self.in_group = ButtonGroup() for i in range(self.neurons): checked = i == self.in_neuron button = JRadioButtonMenuItem( "%s[%d]" % ("in", i), checked, actionPerformed=lambda x, i=i: self.set_in_neuron(i) ) in_menu.add(button) self.in_group.add(button) self.popup.add(in_menu) out_menu = JMenu("out neuron") self.in_group = ButtonGroup() for i in range(self.neurons): checked = i == self.out_neuron button = JRadioButtonMenuItem( "%s[%d]" % ("out", i), checked, actionPerformed=lambda x, i=i: self.set_out_neuron(i) ) out_menu.add(button) self.in_group.add(button) self.popup.add(out_menu)
def __init__(self, repository): self.repository = repository # want a better solution, with domains, perhaps user specifies self.currentUserReference = System.getProperty("user.name") self.currentRecord = None self.window = JFrame("Pointrel browser", windowClosing=self.exit) self.window.contentPane.layout = BorderLayout() # redundant as the default self.window.bounds = (100, 100, 800, 600) self.menuBar = JMenuBar() self.window.JMenuBar = self.menuBar fileMenu = JMenu("File") fileMenu.add(JMenuItem("Open...", actionPerformed=self.open)) fileMenu.add(JMenuItem("Reload", actionPerformed=self.reloadPressed)) fileMenu.addSeparator() fileMenu.add(JMenuItem("Import from other repository...", actionPerformed=self.importFromOtherRepository)) fileMenu.addSeparator() fileMenu.add(JMenuItem("Close", actionPerformed=self.close)) self.menuBar.add(fileMenu) exportMenu = JMenu("Export") exportMenu.add(JMenuItem("Choose current export file...", actionPerformed=self.exportChooseCurrentFile)) exportMenu.addSeparator() exportMenu.add(JMenuItem("Export selected record", actionPerformed=self.exportSelectedRecord)) exportMenu.add(JMenuItem("Export record history for selected attribute", actionPerformed=self.exportAllRecordsForSelectedAttribute)) exportMenu.addSeparator() exportMenu.add(JMenuItem("Export current records for all attributes of selected entity", actionPerformed=self.exportLatestRecordsForSelectedEntity)) exportMenu.add(JMenuItem("Export entire record history for all attributes of selected entity", actionPerformed=self.exportAllRecordsForSelectedEntity)) self.menuBar.add(exportMenu) self.exportFileName = "export.pointrel" #self.reloadButton = JButton("Reload Repository", actionPerformed=self.reloadPressed) self.entitiesList = JList(DefaultListModel(), mouseClicked=self.entitiesListClicked) self.entitiesList.model.addElement("root") self.entitiesList.mousePressed = self.entitiesListMousePressed self.entitiesList.mouseReleased = self.entitiesListMousePressed self.attributesList = JList(DefaultListModel(), mouseClicked=self.attributesListClicked) self.versionsList = JList(DefaultListModel(), mouseClicked=self.versionsListClicked) self.listPanel = JPanel(layout=GridLayout(1, 2)) self.listPanel.add(JScrollPane(self.entitiesList)) self.listPanel.add(JScrollPane(self.attributesList)) self.listPanel.add(JScrollPane(self.versionsList)) self.navigationPanel = JPanel(layout=BorderLayout()) #self.navigationPanel.add(self.reloadButton, BorderLayout.NORTH) self.navigationPanel.add(self.listPanel, BorderLayout.CENTER) self.entityTextField = JTextField(preferredSize=(200,20)) self.attributeTextField = JTextField(preferredSize=(200,20)) self.deletedButton = JCheckBox("Deleted", actionPerformed=self.deletedPressed) # only one right now -- and no support for switching editor panels yet examples = ["pointrel:text/utf-8", ] self.valueTypeComboBox = JComboBox(examples, preferredSize=(200,20), editable=True) self.attributePanel = Box(BoxLayout.X_AXIS) self.attributePanel.add(Box.createRigidArea(Dimension(5,0))) self.attributePanel.add(JLabel("Entity:")) self.attributePanel.add(Box.createRigidArea(Dimension(2,0))) self.attributePanel.add(self.entityTextField) self.attributePanel.add(Box.createRigidArea(Dimension(5,0))) self.attributePanel.add(JLabel("Attribute:")) self.attributePanel.add(Box.createRigidArea(Dimension(2,0))) self.attributePanel.add(self.attributeTextField) self.attributePanel.add(Box.createRigidArea(Dimension(5,0))) self.attributePanel.add(JLabel("Value type:")) self.attributePanel.add(Box.createRigidArea(Dimension(2,0))) self.attributePanel.add(self.valueTypeComboBox) self.attributePanel.add(Box.createRigidArea(Dimension(5,0))) self.attributePanel.add(self.deletedButton) self.attributePanel.add(Box.createRigidArea(Dimension(5,0))) self.showAllDeletedButton = JCheckBox("Show all deleted", actionPerformed=self.showAllDeletedPressed) self.statusText = JTextField(preferredSize=(100,20)) self.saveButton = JButton("Save", actionPerformed=self.savePressed) self.normalSaveButtonColor = self.saveButton.background self.changedSaveButtonColor = Color.YELLOW self.statusPanel = Box(BoxLayout.X_AXIS) self.statusPanel.add(Box.createRigidArea(Dimension(5,0))) self.statusPanel.add(self.showAllDeletedButton) self.statusPanel.add(Box.createRigidArea(Dimension(25,0))) self.statusPanel.add(JLabel("Message:") ) self.statusPanel.add(Box.createRigidArea(Dimension(2,0))) self.statusPanel.add(self.statusText) self.statusPanel.add(Box.createRigidArea(Dimension(5,0))) self.statusPanel.add(self.saveButton) self.statusPanel.add(Box.createRigidArea(Dimension(1,0))) self.currentEditorPanel = EditorPanel_text_utf_8(self, "pointrel:text/utf-8") self.topPanel = Box(BoxLayout.Y_AXIS) self.topPanel.add(Box.createRigidArea(Dimension(0,5))) self.topPanel.add(self.attributePanel) self.topPanel.add(Box.createRigidArea(Dimension(0,5))) self.editorPanel = JPanel(layout=BorderLayout()) self.editorPanel.add(self.topPanel, BorderLayout.NORTH) self.editorPanel.add(self.currentEditorPanel, BorderLayout.CENTER) self.editorPanel.add(self.statusPanel, BorderLayout.SOUTH) self.browserPanel = JSplitPane(JSplitPane.VERTICAL_SPLIT) self.browserPanel.add(self.navigationPanel) self.browserPanel.add(self.editorPanel) self.window.contentPane.add(self.browserPanel, BorderLayout.CENTER) self.setTitleForRepository() self.window.show() # background timer for updating save button color self.timer = Timer(1000, CallbackActionListener(self.timerEvent)) self.timer.initialDelay = 1000 self.timer.start()
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()
def __init__(self, label, style=NengoStyle()): BaseMenuBuilder.__init__(self, style) self.menu = JMenu(label) self.isFirstSection = True if style is not None: self.applyStyle(self.menu, self.style)
def menu(self): f = JMenu("File") o = JMenuItem("Copy") o.addActionListener(ActionEventListener(self.opencopy)) self.open = o f.add(o) o = JMenuItem("New") o.addActionListener(ActionEventListener(self.new)) self.open = o f.add(o) o = JMenuItem("Open") o.addActionListener(ActionEventListener(self.opendialog)) self.open = o f.add(o) o = JMenuItem("Save") o.addActionListener(ActionEventListener(self.save)) self.open = o f.add(o) o = JMenuItem("Save As") o.addActionListener(ActionEventListener(self.saveas)) self.open = o f.add(o) return f
def __init__(self, app, menuTitle): JMenu.__init__(self, menuTitle) self.app = app #quat dialog item dialogItem = JCheckBoxMenuItem(self.app.dlg.toggleAction) self.add(dialogItem) self.addSeparator() #tool submenu for tool in self.app.tools: if tool.name == "favourites": self.addSeparator() toolMenu = JMenu(tool.title) toolMenu.setIcon(tool.bigIcon) if tool.uri != "": #Website link iconFile = File.separator.join([self.app.SCRIPTDIR, "images", "icons", "browser.png"]) urlItem = JMenuItem(tool.title) urlItem.setIcon(ImageIcon(iconFile)) urlItem.addActionListener(QatMenuActionListener(self.app, "link", tool)) toolMenu.add(urlItem) toolMenu.addSeparator() #View submenu for view in tool.views: viewMenu = JMenu(view.title) if tool.name == "favourites": self.app.favouritesMenu = viewMenu #Check item for check in view.checks: self.add_check_item(tool, view, check, viewMenu) toolMenu.add(viewMenu) self.add(toolMenu) #Local file with errors localFileItem = JMenuItem(self.app.strings.getString("Open_GPX")) localFileItem.setIcon(ImageProvider.get("open")) localFileItem.addActionListener(QatMenuActionListener(self.app, "local file")) self.add(localFileItem) self.addSeparator() #False positive dialog falsepositiveItem = JMenuItem(self.app.strings.getString("False_positives...")) falsepositiveItem.addActionListener(QatMenuActionListener(self.app, "dialog")) self.add(falsepositiveItem) #Preferences dialog preferencesItem = JMenuItem(self.app.strings.getString("Preferences...")) preferencesItem.addActionListener(QatMenuActionListener(self.app, "dialog")) self.add(preferencesItem) #About dialog item aboutItem = JMenuItem(self.app.strings.getString("About...")) aboutItem.addActionListener(QatMenuActionListener(self.app, "dialog")) self.add(aboutItem)
def createMenuBar(manager): global menuHandles, isDominant, isTemporal menuHandles = {} menuBar = JMenuBar() fmenu = JMenu("File") menuHandles['File'] = fmenu fmenu.setMnemonic(KeyEvent.VK_F) menuBar.add(fmenu) fmenu.add(createMenuItem('Open Genepop data', "Open", manager)) fmenu.add(createMenuItem('Use Example data', "Example", manager)) fmenu.addSeparator() fmenu.add(createMenuItem('Citation', "Citation", manager)) fmenu.addSeparator() fmenu.add(createMenuItem("Exit", "Exit", manager)) if not isTemporal: pmenu = JMenu("Populations") menuHandles['Populations'] = pmenu pmenu.setEnabled(False) pmenu.setMnemonic(KeyEvent.VK_P) menuBar.add(pmenu) pmenu.add(createMenuItem('Load population names', "LoadPop", manager)) pmenu.add(createMenuItem('Edit population names', "EditPop", manager)) pmenu.add(createMenuItem('Save population names', "SavePop", manager)) umenu = JMenu("Data used") menuHandles['Data used'] = umenu umenu.setEnabled(False) umenu.setMnemonic(KeyEvent.VK_U) menuBar.add(umenu) umenu.add(createMenuItem('Loci Analyzed', "ChooseLoci", manager)) if isTemporal: umenu.add(createMenuItem('Samples Analyzed', "ChoosePops", manager)) else: umenu.add(createMenuItem('Populations Analyzed', "ChoosePops", manager)) if isDominant: fdmenu = JMenu("DFDist") elif isTemporal: fdmenu = JMenu("FTemp") else: fdmenu = JMenu("FDist") menuHandles['FDist'] = fdmenu fdmenu.setEnabled(False) fdmenu.setMnemonic(KeyEvent.VK_D) menuBar.add(fdmenu) if isTemporal: fdmenu.add(createMenuItem('Run FTemp', "RunFDist", manager)) else: fdmenu.add(createMenuItem('Run FDist', "RunFDist", manager)) item5000 = createMenuItem('Run more 5000 sims', "Run5000", manager) item5000.setEnabled(False) menuHandles['item5000'] = item5000 fdmenu.add(item5000) checkLoci = createMenuItem('Check Loci Status', "CheckLoci", manager) checkLoci.setEnabled(False) menuHandles['checkLoci'] = checkLoci fdmenu.add(checkLoci) gmenu = JMenu("Graphic") gmenu.setEnabled(False) menuHandles['Graphic'] = gmenu gmenu.setMnemonic(KeyEvent.VK_G) menuBar.add(gmenu) gmenu.add(createMenuItem('Colors and loci labels', "ConfGrp", manager)) #gmenu.add(createMenuItem('Save Graphic as PNG', "SavePNG", manager)) gmenu.add(createMenuItem('Save as PNG', "SavePNG", manager)) gmenu.add(createMenuItem('Export as PDF', "SavePDF", manager)) gmenu.add(createMenuItem('Export as SVG', "SaveSVG", manager)) menuBar.add(Box.createHorizontalGlue()) hmenu = JMenu("Help") hmenu.setMnemonic(KeyEvent.VK_H) menuBar.add(hmenu) hmenu.add(createMenuItem('Help', "Help", manager)) return menuBar
def run(scene, w=512, h=512, aa=1, threads=1): """Create GUI and perform ray-tracing.""" # Make Swing not look like garbage (so much) UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) # Setup frame frame = JFrame("RayTracer", defaultCloseOperation=JFrame.EXIT_ON_CLOSE, size=(w, h)) frame.setIconImage(ImageIcon("resources/icon.png").getImage()) canvas = RayTracePanel(w, h, aa, threads) frame.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 exit(event): """Performed when the exit button is pressed""" import sys sys.exit(0) 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) frame.setJMenuBar(menuBar) # Finish initializing GUI self.pack()
def run(scene, w=512, h=512, aa=1, threads=1): '''Create GUI and perform ray-tracing.''' #Make Swing not look like garbage (so much) UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()) #Setup frame frame = JFrame( "RayTracer", defaultCloseOperation=JFrame.EXIT_ON_CLOSE, size=(w, h) ) frame.setIconImage(ImageIcon('resources/icon.png').getImage()) canvas = RayTracePanel(w, h, aa, threads) frame.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).start() def exit(event): '''Performed when the exit button is pressed''' import sys sys.exit(0) #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() closeButton = JMenuItem('Close', actionPerformed=exit) closeButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK)) menu.add(closeButton) frame.setJMenuBar(menuBar) #Finish initializing GUI frame.pack() #frame.setLocationRelativeTo(None) frame.setVisible(True) #Perform ray-tracing if scene is not None: Thread(Painter(canvas, scene, openButton, saveButton)).start()
def make_menubar(self): shortcut = Toolkit.getDefaultToolkit().menuShortcutKeyMask menubar = JMenuBar() def new_item(title, cmd, key, mod=shortcut): item = JMenuItem(title, actionCommand=cmd) item.accelerator = KeyStroke.getKeyStroke(key, mod) item.addActionListener(self) return item filemenu = JMenu("File") menubar.add(filemenu) fm = self.file_manager = FileManager(self) item = new_item("Run Python File...", "load", KeyEvent.VK_L) filemenu.add(item) item = new_item("Run Python File", "reload", KeyEvent.VK_R) item.enabled = False self.reload_menuitem = item filemenu.add(item) filemenu.addSeparator() item = new_item("Open Python Script...", "open", KeyEvent.VK_O) filemenu.add(item) item = new_item("Save Python Script", "save", KeyEvent.VK_S) item.enabled = False self.save_menuitem = item filemenu.add(item) item = new_item("Save Python Script As...", "save_as", KeyEvent.VK_S, mod = shortcut + ActionEvent.SHIFT_MASK) filemenu.add(item) editmenu = JMenu("Edit") menubar.add(editmenu) editmenu.add(new_item("Cut", "cut", KeyEvent.VK_X)) editmenu.add(new_item("Copy", "copy", KeyEvent.VK_C)) editmenu.add(new_item("Paste", "paste", KeyEvent.VK_V)) editmenu.addSeparator() item = new_item("Run Script", "runscript", KeyEvent.VK_E) editmenu.add(item) item = new_item("Run Selection", "runselection", KeyEvent.VK_E, mod=shortcut | ActionEvent.SHIFT_MASK) editmenu.add(item) editmenu.addSeparator() item = new_item("Indent Selection", "indentselection", KeyEvent.VK_CLOSE_BRACKET) editmenu.add(item) item = new_item("Dedent Selection", "dedentselection", KeyEvent.VK_OPEN_BRACKET) editmenu.add(item) shellmenu = JMenu("Interactive") menubar.add(shellmenu) item = new_item("Previous Input", "up", KeyEvent.VK_UP, mod=ActionEvent.ALT_MASK) shellmenu.add(item) item = new_item("Next Input", "down", KeyEvent.VK_DOWN, mod=ActionEvent.ALT_MASK) shellmenu.add(item) self.frame.setJMenuBar(menubar)
def __init__(self): ''' Constructor ''' #Create classifiers #Character classifier path_to_this_dir = File(str(inspect.getfile( inspect.currentframe() ))).getParent() character_classifier_file = open(File(path_to_this_dir,"character_classifier.dat").getPath(),'r') self.character_classifier = CharacterClassifier(from_string_string=character_classifier_file.read()) character_classifier_file.close() #Word classifier word_classifier_file = open(File(path_to_this_dir,"word_classifier.dat").getPath(),'r') self.word_classifier= WordClassifier(from_string_string=word_classifier_file.read()) word_classifier_file.close() #Set up window self.setTitle("HandReco Writer") self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) self.setLocationRelativeTo(None) self.setLayout(BorderLayout()) #Set up menu menu_bar = JMenuBar() info_menu = JMenu("Info") def instructions(event): instr = ''' The program can just recognise capital English characters. See Info -> Available Words... for available word corrections. Good Luck with the writing!''' JOptionPane.showMessageDialog(self, instr, "Instructions", JOptionPane.INFORMATION_MESSAGE) instructions_menu_item = JMenuItem("Instructions...",actionPerformed=instructions) info_menu.add(instructions_menu_item) def word_corrections(event): words_string = "" for word in self.word_classifier.words: words_string = words_string + word.upper() + "\n" text = "The words that can be corrected are:\n\n" +words_string dialog = JOptionPane(text, JOptionPane.INFORMATION_MESSAGE) dialog_wrapper = JDialog(self,"Available Words",False) dialog_wrapper.setContentPane(dialog) dialog_wrapper.pack() dialog_wrapper.setVisible(True) word_corrections_menu_item = JMenuItem("Available Words...",actionPerformed=word_corrections) info_menu.add(word_corrections_menu_item) menu_bar.add(info_menu) self.setJMenuBar(menu_bar) #Input panel input_panel = JPanel() input_panel.setLayout(BoxLayout(input_panel, BoxLayout.X_AXIS)) input_panel.setBorder(BorderFactory.createTitledBorder("Input")) self.paint_area = PaintArea(100,100) input_panel.add(self.paint_area) input_options_panel = JPanel() input_options_panel.setLayout(BoxLayout(input_options_panel, BoxLayout.Y_AXIS)) #Write Char write_char_panel = JPanel(BorderLayout()) def write_char(event): char = self.character_classifier.classify_image(self.paint_area.image()) self.text_area.setText(self.text_area.getText() + char) self.paint_area.clear() write_char_panel.add(JButton("Write Char", actionPerformed=write_char), BorderLayout.NORTH) input_options_panel.add(write_char_panel) #Space and Correct space_and_correct_panel = JPanel(BorderLayout()) def space_and_correct(event): text = self.text_area.getText() words = text.split(" ") string = words[-1] try: word = self.word_classifier.classify(string.lower()) words[-1] = word.upper() except: JOptionPane.showMessageDialog(self, "Have you entered a character which is not in the alphabet?", "Could not Correct", JOptionPane.ERROR_MESSAGE) self.text_area.setText(text + " ") return newText = "" for w in words: newText = newText + w + " " self.text_area.setText(newText) space_and_correct_panel.add(JButton("Space and Correct", actionPerformed=space_and_correct), BorderLayout.NORTH) input_options_panel.add(space_and_correct_panel) #Space space_panel = JPanel(BorderLayout()) def space(event): self.text_area.setText(self.text_area.getText() + " ") space_panel.add(JButton("Space", actionPerformed=space), BorderLayout.NORTH) input_options_panel.add(space_panel) #Clear Input Area clear_input_area_panel = JPanel(BorderLayout()) def clear(event): self.paint_area.clear() clear_input_area_panel.add(JButton("Clear Input Area", actionPerformed=clear), BorderLayout.NORTH) input_options_panel.add(clear_input_area_panel) input_panel.add(input_options_panel) self.add(input_panel, BorderLayout.NORTH) text_area_panel = JPanel() text_area_panel.setLayout(BorderLayout()) text_area_panel.setBorder(BorderFactory.createTitledBorder("Text")) self.text_area = JTextArea() self.text_area.setLineWrap(True) #Increase font size font = self.text_area.getFont() self.text_area.setFont(Font(font.getName(), Font.BOLD, 24)) text_area_panel.add(JScrollPane(self.text_area), BorderLayout.CENTER) self.add(text_area_panel, BorderLayout.CENTER) self.pack() self.setSize(Dimension(300,300)) self.setVisible(True)
from jyVis import JyVis from jyVis.widgets import JLMenuItem from javax.swing import JMenuBar, JMenu baseWindow = JyVis.getBaseWindow() menuBar = JMenuBar() fileMenu = JMenu("File") fileMenu.add(JLMenuItem("Open Dataset",JyVis.promptUserToOpenDataTable)) fileMenu.add(JLMenuItem("Save Session",JyVis.promptUserToSaveSession)) fileMenu.add(JLMenuItem("Load Session",JyVis.promptUserToReplaySession)) fileMenu.add(JLMenuItem("Export Selection as CSV",JyVis.promptUserToExportSelection)) fileMenu.add(JLMenuItem("Export Image as PNG",JyVis.promptUserToExportImageAsPNG)) fileMenu.addSeparator() fileMenu.add(JLMenuItem("Properties","JyVis.showSystemPropertyPanel()")) #TODO remove this fileMenu.add(JLMenuItem("RTest","JyVis.doRTest()")) menuBar.add(fileMenu) # build the Visualizations menu from the contents of the plugin directory visMenu = JyVis.createMenuForScriptDirectory("run//Visualizations") if(visMenu != None): menuBar.add(visMenu)
def actionCallback(e): if e.getSource() == goItem: wakeUp() if e.getSource() == exitItem: dispose() if e.getSource() == aboutItem: msgDlg("Pyramides Version 1.0") def doIt(): clear() for i in range(1, 30): setColor(getRandomX11Color()) fillRectangle(i/2, i - 0.35, 30 - i/2, i + 0.35) fileMenu = JMenu("File") goItem = JMenuItem("Go", actionPerformed = actionCallback) exitItem = JMenuItem("Exit", actionPerformed = actionCallback) fileMenu.add(goItem) fileMenu.add(exitItem) aboutItem = JMenuItem("About", actionPerformed = actionCallback) menuBar = JMenuBar() menuBar.add(fileMenu) menuBar.add(aboutItem) makeGPanel(menuBar, 0, 30, 0, 30) while not isDisposed(): putSleep()
def setMenuBar(self): menuBar = JMenuBar() menuApp = JMenu("Apps") menuApp.setMnemonic('A') menuSettings = JMenu("Settings") menuSettings.setMnemonic('S') #set submenus menuPlayNow = JMenu("PlayNow" ) menuPlayNowOpen = JMenuItem("Open", actionPerformed = (lambda x, param="open": self.playNowApp_startThread(param)) ) menuPlayNow.add(menuPlayNowOpen) menuPlayNowLogin = JMenuItem("Login", actionPerformed = lambda x, action="playNowLogin": self.playNowApp_startThread(action) ) menuPlayNow.add(menuPlayNowLogin) menuPlayNowClose = JMenuItem("Close", actionPerformed = lambda x, action="playNowClose": self.playNowApp_startThread(action) ) menuPlayNow.add(menuPlayNowClose) menuPokerTable = JMenu("PokerTable") menuPokerTableJoin = JMenuItem("Find Practice Table", actionPerformed = lambda x, action="practiceTable": self.playNowApp_startThread(action) ) menuPokerTable.add(menuPokerTableJoin) menuPokerTableJoin = JMenuItem("Join Table", actionPerformed = lambda x, action="joinTable": self.playNowApp_startThread(action) ) menuPokerTable.add(menuPokerTableJoin) menuPokerTableAddChips = JMenuItem("Add Chips", actionPerformed = lambda x, action="addChips": self.playNowApp_startThread(action) ) menuPokerTable.add(menuPokerTableAddChips) menuPokerTableSitOut = JMenuItem("Sit Out", actionPerformed = lambda x, action="sitOut": self.playNowApp_startThread(action) ) menuPokerTable.add(menuPokerTableSitOut) menuPokerTableLeaveTable = JMenuItem("Leave Table", actionPerformed = lambda x, action="leaveTable": self.playNowApp_startThread(action) ) menuPokerTable.add(menuPokerTableLeaveTable) menuPokerAppExit = JMenuItem("Exit") menuApp.add(menuPlayNow) menuApp.add(menuPokerTable) menuApp.addSeparator() menuApp.add(menuPokerAppExit) menuBar.add(menuApp) menuBar.add(menuSettings) self._frame.setJMenuBar(menuBar)
def makeEditorFrame(ldPath, compiler): mb = JMenuBar() file = JMenu("File") edit = JMenu("Edit") run = JMenu("Run") newMenu = menu_with_accelerator("New",(KeyEvent.VK_N,ActionEvent.META_MASK)) file.add(newMenu) open = menu_with_accelerator("Open",(KeyEvent.VK_O,ActionEvent.META_MASK)) file.add(open) save = menu_with_accelerator("Save",(KeyEvent.VK_S,ActionEvent.META_MASK)) file.add(save) file.add(JSeparator()); resetPipe = menu_with_accelerator("Reset Pipeline",(KeyEvent.VK_N,ActionEvent.META_MASK | ActionEvent.SHIFT_MASK)) file.add(resetPipe) openPipe = menu_with_accelerator("Open Pipeline",(KeyEvent.VK_O,ActionEvent.META_MASK | ActionEvent.SHIFT_MASK)) file.add(openPipe) compile = menu_with_accelerator("Compile",(KeyEvent.VK_ENTER, ActionEvent.META_MASK)) run.add(compile) mb.add(file) mb.add(edit) mb.add(run) f = JFrame("SFGP Shader Editor") f.setJMenuBar(mb) c = f.getContentPane() c.setLayout(BorderLayout()) editor = GLSLEditorPane("",ldPath,compiler) c.add(editor, BorderLayout.CENTER) c.doLayout() f.setSize(1000, 700); f.setVisible(True); f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); class EditorActionListener(ActionListener): def makeRelay(srcObj): return (lambda e: editor.actionPerformed(ActionEvent(srcObj, e.getID(), e.getActionCommand()))) editorActions = { save : (lambda e: editor.saveCurrent()), compile : (lambda e: editor.compileCurrent()), open : makeRelay(editor.openShader), newMenu : makeRelay(editor.newShader), openPipe : makeRelay(editor.openPipeline), resetPipe : makeRelay(editor.resetPipeline) } def actionPerformed(self, e): editorActions = EditorActionListener.editorActions evtSrc = e.getSource() if evtSrc in editorActions: editorActions[evtSrc](e) else: raise IllegalStateException("Imaginary menu item registered an ActionEvent: " + evtSrc) menuListener = EditorActionListener() compile.addActionListener(menuListener); newMenu.addActionListener(menuListener); open.addActionListener(menuListener); save.addActionListener(menuListener); resetPipe.addActionListener(menuListener); openPipe.addActionListener(menuListener);