当前位置: 首页>>代码示例>>Python>>正文


Python JComboBox.getSelectedItem方法代码示例

本文整理汇总了Python中javax.swing.JComboBox.getSelectedItem方法的典型用法代码示例。如果您正苦于以下问题:Python JComboBox.getSelectedItem方法的具体用法?Python JComboBox.getSelectedItem怎么用?Python JComboBox.getSelectedItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JComboBox的用法示例。


在下文中一共展示了JComboBox.getSelectedItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import getSelectedItem [as 别名]
class _AccountAdder:
    def __init__(self, contactslist):
        self.contactslist = contactslist
        self.mainframe = JFrame("Add New Contact")
        self.account = JComboBox(self.contactslist.clientsByName.keys())
        self.contactname = JTextField()
        self.buildpane()

    def buildpane(self):
        buttons = JPanel()
        buttons.add(JButton("OK", actionPerformed=self.add))
        buttons.add(JButton("Cancel", actionPerformed=self.cancel))

        acct = JPanel(GridLayout(1, 2), doublebuffered)
        acct.add(JLabel("Account"))
        acct.add(self.account)

        mainpane = self.mainframe.getContentPane()
        mainpane.setLayout(BoxLayout(mainpane, BoxLayout.Y_AXIS))
        mainpane.add(self.contactname)
        mainpane.add(acct)
        mainpane.add(buttons)
        self.mainframe.pack()
        self.mainframe.show()

    #action listeners
    def add(self, ae):
        acct = self.contactslist.clientsByName[self.account.getSelectedItem()]
        acct.addContact(self.contactname.getText())
        self.mainframe.dispose()

    def cancel(self, ae):
        self.mainframe.dispose()
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:35,代码来源:jychat.py

示例2: EditSymbolAttr

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import getSelectedItem [as 别名]
class EditSymbolAttr(JPanel):
    def __init__(self, sattr):
	self.attr = sattr
	self.cbox = JColorChooser(self.attr.color)
	self.sz_field = JTextField(str(self.attr.size))
	szpanel = JPanel()
	szpanel.add(self.sz_field)
	szpanel.setBorder(BorderFactory.createTitledBorder("symbol size (integer)"))
	self.filled_box = JCheckBox("Filled ?:",self.attr.filled)
	self.shape_cbox = JComboBox(SymbolProps.sym_shape_map.keys())
	self.shape_cbox.setSelectedItem(self.attr.shape)
	self.shape_cbox.setBorder(BorderFactory.createTitledBorder("Shape"))
	panel1 = JPanel()
	panel1.setLayout(BorderLayout())
	panel1.add(szpanel,BorderLayout.NORTH)
	panel2 = JPanel()
	panel2.setLayout(GridLayout(1,2))
	panel2.add(self.shape_cbox)
	panel2.add(self.filled_box)
	panel1.add(panel2,BorderLayout.SOUTH)
	self.setLayout(BorderLayout())
	self.add(self.cbox,BorderLayout.CENTER)
	self.add(panel1,BorderLayout.SOUTH)
    def setAttribute(self,sattr):
	self.attr = sattr
	self.cbox.color = self.attr.color
	self.sz_field.text = str(self.attr.size)
	self.shape_cbox.setSelectedItem(self.attr.shape)
    def update(self):
	self.attr.color = self.cbox.getColor()
	self.attr.size = string.atoi(self.sz_field.getText())
	self.attr.filled = self.filled_box.isSelected()
	self.attr.shape = self.shape_cbox.getSelectedItem()
	self.attr.sym = self.attr.createSymbol()
开发者ID:CalSimCalLite,项目名称:CalLiteGUI,代码行数:36,代码来源:xattr.py

示例3: PrefsPanel

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import getSelectedItem [as 别名]
class PrefsPanel(JPanel):
    """JPanle with gui for tool preferences
    """
    def __init__(self, app):
        strings = app.strings

        self.setLayout(GridLayout(3, 2, 5, 5))
        userLbl = JLabel(strings.getString("osmose_pref_username"))
        self.userTextField = JTextField(20)
        self.userTextField.setToolTipText(strings.getString("osmose_pref_username_tooltip"))

        levelLbl = JLabel(strings.getString("osmose_pref_level"))
        self.levels = ["1", "1,2", "1,2,3", "2", "3"]
        self.levelsCombo = JComboBox(self.levels)
        self.levelsCombo.setToolTipText(strings.getString("osmose_pref_level_tooltip"))

        limitLbl = JLabel(strings.getString("osmose_pref_limit"))
        self.limitTextField = JTextField(20)
        self.limitTextField.setToolTipText(strings.getString("osmose_pref_limit_tooltip"))

        self.add(userLbl)
        self.add(self.userTextField)
        self.add(levelLbl)
        self.add(self.levelsCombo)
        self.add(limitLbl)
        self.add(self.limitTextField)

    def update_gui(self, preferences):
        """Update preferences gui
        """
        self.userTextField.setText(preferences["username"])
        self.levelsCombo.setSelectedIndex(self.levels.index(preferences["level"]))
        self.limitTextField.setText(str(preferences["limit"]))

    def read_gui(self):
        """Read preferences from gui
        """
        username = self.userTextField.getText()
        level = self.levelsCombo.getSelectedItem()
        limit = self.limitTextField.getText()
        try:
            limit = Integer.parseInt(limit)
            if limit > 500:
                limit = 500
            limit = str(limit)
        except NumberFormatException:
            limit = ""

        preferences = {"username": username.strip(),
                       "level": level,
                       "limit": limit}
        return preferences
开发者ID:alex85k,项目名称:qat_script,代码行数:54,代码来源:Osmose_prefs_gui.py

示例4: EditCurveAttr

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import getSelectedItem [as 别名]
class EditCurveAttr(JPanel):
    def __init__(self, cattr):
	self.attr = cattr
	self.cbox = JColorChooser(self.attr.color)
	self.sym_panel = EditSymbolAttr(cattr.sym_prop)
	self.thickness_field = JTextField(str(cattr.thickness),2)
	self.draw_symbol_box = JCheckBox("Draw Symbol?",cattr.draw_symbol)
	self.dps_field = JTextField(str(self.attr.data_per_symbol),2)
	self.dash_box = JComboBox(CurveProps.DASH_TYPES.keys())
	self.dash_box.setSelectedItem(self.attr.dash_type)
	self.dash_box.setBorder(BorderFactory.createTitledBorder("Dash type: (Only JDK2 & Slow!)"))
	tpanelx = JPanel()
	tpanelx.add(self.thickness_field)
	tpanelx.setBorder(BorderFactory.createTitledBorder("curve thickness (integer)"))
	tpanely = JPanel()
	tpanely.add(self.dps_field)
	tpanely.setBorder(BorderFactory.createTitledBorder("data per symbol(integer)"))
	tpanel = JPanel();tpanel.setLayout(GridLayout(2,2));
	tpanel.add(self.draw_symbol_box); tpanel.add(tpanelx);
	tpanel.add(tpanely); tpanel.add(self.dash_box);
	panel1 = JPanel()
	panel1.setLayout(BorderLayout())
	panel1.add(self.cbox,BorderLayout.CENTER)
	panel1.add(tpanel, BorderLayout.SOUTH)
	panel2 = JPanel()
	panel2.setLayout(BorderLayout())
	panel2.add(self.sym_panel,BorderLayout.CENTER)
	tp1 = JTabbedPane()
	tp1.addTab("Curve Attributes",panel1)
	tp1.addTab("Symbol Attributes",panel2)
	tp1.setSelectedComponent(panel1)
	self.setLayout(BorderLayout())
	self.add(tp1,BorderLayout.CENTER)
    def setAttribute(self,cattr):
	self.attr = cattr
	self.cbox.color = self.attr.color
	self.sym_panel.setAttribute(cattr.sym_prop)
	self.thickness_field.text = str(cattr.thickness)
	self.dps_field.text = str(cattr.data_per_symbol)
	self.draw_symbol_box.setSelected(cattr.draw_symbol)
	self.dash_box.setSelectedItem(cattr.dash_type)
    def update(self):
	self.attr.color = self.cbox.getColor()
	self.attr.thickness = string.atoi(self.thickness_field.text)
	self.attr.data_per_symbol = string.atoi(self.dps_field.text)
	self.attr.draw_symbol = self.draw_symbol_box.isSelected()
	self.attr.dash_type = self.dash_box.getSelectedItem()
	#print 'Updating Self.draw_symbol',self.draw_symbol,self.attr
	self.sym_panel.update()
开发者ID:CalSimCalLite,项目名称:CalLiteGUI,代码行数:51,代码来源:xattr.py

示例5: C5Panel

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import getSelectedItem [as 别名]
class C5Panel(JPanel):
	def __init__(self,hostname):
		
		self.hostname=hostname
		
		JPanel.__init__(self,BorderLayout())
		self.cbActionListener=foo2(self)
		
		#imglist=os.listdir('./img')
		#try:imglist.remove('.svn')
		#except:pass
		imglist=['01-CircleOfFifths.gif','Fifths.png','circle-o-fifths.jpg','Circle_Of_Fifths.gif','Keywheel.gif','circle-of-fifths.gif','ColorFifths.jpg','cof.gif']
		
		self.cb=JComboBox(imglist,actionListener=self.cbActionListener)#
		#self.cb.addItemListener(self.cbCB)
		tb=JPanel()
		tb.setLayout(FlowLayout(FlowLayout.CENTER))
		tb.add(self.cb)
		self.add(tb,'Center')
		
		self.img=None
		if hostname[0:7]=='http://':
			self.img=ImageIO.read(URL(self.hostname+'/static/sightreadingtrainer/img/'+imglist[0]))
		else:
			self.img=ImageIO.read(File(self.hostname+'img/'+imglist[0]))
		
		icon=ImageIcon(self.img)
		self.label=JLabel(icon)
		self.add(self.label,'North')
	
	
	def cbCB(self,e):
		try:
			item=self.cb.getSelectedItem()
			if DEBUG:print item
			if self.hostname[0:7]=='http://':
				self.img=ImageIO.read(URL(self.hostname+'/static/sightreadingtrainer/img/'+item))
			else:
				self.img=ImageIO.read(File(self.hostname+'img/'+item))
			
			if DEBUG:print self.img
			icon=ImageIcon(self.img)
			self.label.setIcon(icon)
		except Exception,e:
			if DEBUG:print e
开发者ID:asymptopia,项目名称:sightreadingtrainer,代码行数:47,代码来源:c5panel.py

示例6: SignInputPanel

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import getSelectedItem [as 别名]
class SignInputPanel(PropertyInputPanel,DocumentListener):
    def __init__(self,property):
        PropertyInputPanel.__init__(self,property)
        self.comboBox = JComboBox(["Unconstrained", "Positive", "Negative"])
        self.add(self.comboBox)

    def isValueSet(self):
        return True
    def getValue(self):
        item = self.comboBox.getSelectedItem()
        if item=="Positive":
            return 1
        elif item =="Negative":
            return -1
        else:
            return 0
    def setValue(self, value):
        pass
开发者ID:Elhamahm,项目名称:nengo_1.4,代码行数:20,代码来源:networkarray.py

示例7: GameSelector

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import getSelectedItem [as 别名]
class GameSelector(ActionListener):
    """ generated source for class GameSelector """

    theGameList = JComboBox()
    theRepositoryList = JComboBox()
    theSelectedRepository = GameRepository()
    theCachedRepositories = Map()

    class NamedItem(object):
        """ generated source for class NamedItem """

        theKey = str()
        theName = str()

        def __init__(self, theKey, theName):
            """ generated source for method __init__ """
            self.theKey = theKey
            self.theName = theName

        def __str__(self):
            """ generated source for method toString """
            return self.theName

    def __init__(self):
        """ generated source for method __init__ """
        super(GameSelector, self).__init__()
        self.theGameList = JComboBox()
        self.theGameList.addActionListener(self)
        self.theRepositoryList = JComboBox()
        self.theRepositoryList.addActionListener(self)
        self.theCachedRepositories = HashMap()
        self.theRepositoryList.addItem("games.ggp.org/base")
        self.theRepositoryList.addItem("games.ggp.org/dresden")
        self.theRepositoryList.addItem("games.ggp.org/stanford")
        self.theRepositoryList.addItem("Local Game Repository")

    def actionPerformed(self, e):
        """ generated source for method actionPerformed """
        if e.getSource() == self.theRepositoryList:
            if self.theCachedRepositories.containsKey(theRepositoryName):
                self.theSelectedRepository = self.theCachedRepositories.get(theRepositoryName)
            else:
                if theRepositoryName == "Local Game Repository":
                    self.theSelectedRepository = LocalGameRepository()
                else:
                    self.theSelectedRepository = CloudGameRepository(theRepositoryName)
                self.theCachedRepositories.put(theRepositoryName, self.theSelectedRepository)
            repopulateGameList()

    def getSelectedGameRepository(self):
        """ generated source for method getSelectedGameRepository """
        return self.theSelectedRepository

    def repopulateGameList(self):
        """ generated source for method repopulateGameList """
        theRepository = self.getSelectedGameRepository()
        theKeyList = ArrayList(theRepository.getGameKeys())
        Collections.sort(theKeyList)
        self.theGameList.removeAllItems()
        for theKey in theKeyList:
            if theGame == None:
                continue
            if theName == None:
                theName = theKey
            if 24 > len(theName):
                theName = theName.substring(0, 24) + "..."
            self.theGameList.addItem(self.NamedItem(theKey, theName))

    def getRepositoryList(self):
        """ generated source for method getRepositoryList """
        return self.theRepositoryList

    def getGameList(self):
        """ generated source for method getGameList """
        return self.theGameList

    def getSelectedGame(self):
        """ generated source for method getSelectedGame """
        try:
            return self.getSelectedGameRepository().getGame((self.theGameList.getSelectedItem()).theKey)
        except Exception as e:
            return None
开发者ID:hobson,项目名称:ggpy,代码行数:84,代码来源:GameSelector.py

示例8: BurpExtender

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import getSelectedItem [as 别名]

#.........这里部分代码省略.........
        index = 0
        listeners = DefaultComboBoxModel()
        while (("proxy.listener" + str(index)) in config):
            listenerItem = config["proxy.listener" + str(index)]
            listenerItems = listenerItem.split(".")
            if (listenerItems[0] == "1"):
                address = ".".join(listenerItems[2][1:].split("|"))
                if (len(address) == 0):
                    address = "127.0.0.1"
                listeners.addElement(address + " : " + listenerItems[1])

            index = index + 1
        self._listenersCombo.setModel(listeners)
        return;

    #
    # implement button actions
    #
    def startToggled(self, ev):
        if (self._startButton.getModel().isSelected()):
            try:
                os.chdir(sys.path[0] + os.sep + "riacrawler" + os.sep + "scripts")
            except Exception as e:
                print >> sys.stderr, "RIA crawler scripts loading error", "I/O error({0}): {1}".format(e.errno, e.strerror)
                self._startButton.setSelected(False)
                return

            phantomJsPath = self._phantomJsPathField.text
            target = self._addressTextField.text

            config = "crawler.config"
            if (self._configFile):
                config = self._configFile

            listenerAddress = self._listenersCombo.getSelectedItem().replace(" ", "")
            p = Popen("{0} --proxy={3} main.js --target={1} --config={2}".format(phantomJsPath, target, config, listenerAddress), shell=True)
            self._running = True
            self._requestsMadeInfo.setText("")
            self._statesFoundInfo.setText("")
            self._commandClient.startCrawling()
        else:
            if (self._running):
                self._commandClient.stopCrawling()
            self._running = False

    def syncCrawlingState(self, result):
        print "RIA crawling state: ", result
        self._requestsMadeInfo.setText(str(result["requests_made"]))
        self._statesFoundInfo.setText(str(result["states_detected"]))
        if (result["running"] == False):
            self._commandClient.stopCrawling()
            self._running = False
            self._startButton.setSelected(False)

    def loadConfigClicked(self, ev):
        openFile = JFileChooser();
        openFile.showOpenDialog(None);
        self._configFile = openFile.getSelectedFile()

    #
    # implement DocumentListener for _addressTextField
    #
    def removeUpdate(self, ev):
        self.updateStartButton()
    def insertUpdate(self, ev):
        self.updateStartButton()
    def updateStartButton(self):
        self._startButton.setEnabled(len(self._addressTextField.text) > 0)


    #
    # implement IContextMenuFactory
    #
    def createMenuItems(self, contextMenuInvocation):
        menuItemList = ArrayList()

        context = contextMenuInvocation.getInvocationContext()
        if (context == IContextMenuInvocation.CONTEXT_MESSAGE_VIEWER_REQUEST or context == IContextMenuInvocation.CONTEXT_MESSAGE_EDITOR_REQUEST or
            context == IContextMenuInvocation.CONTEXT_PROXY_HISTORY or context == IContextMenuInvocation.CONTEXT_TARGET_SITE_MAP_TABLE):

            self._contextMenuData = contextMenuInvocation.getSelectedMessages()
            menuItemList.add(JMenuItem("Send to Phantom RIA Crawler", actionPerformed = self.menuItemClicked))

        return menuItemList


    def menuItemClicked(self, event):
        if (self._running == True):
            self._callbacks.issueAlert("Can't set data to Phantom RIA Crawler: crawling is running already.")
            return;

        dataIsSet = False;
        for message in self._contextMenuData:
            request = self._helpers.analyzeRequest(message)

            url = request.getUrl().toString()
            print url
            if (url):
                dataisSet = True;
                self._addressTextField.setText(url)
开发者ID:MTuner,项目名称:RiaCrawler,代码行数:104,代码来源:crawler_extension.py

示例9: NewAtfView

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import getSelectedItem [as 别名]

#.........这里部分代码省略.........

        # Set up constraints to tell panel how to position components.
        layout.putConstraint(SpringLayout.WEST,
                             create_button,
                             15,
                             SpringLayout.WEST,
                             panel)
        layout.putConstraint(SpringLayout.NORTH,
                             create_button,
                             15,
                             SpringLayout.NORTH,
                             panel)
        layout.putConstraint(SpringLayout.WEST,
                             leave_button,
                             5,
                             SpringLayout.EAST,
                             create_button)
        layout.putConstraint(SpringLayout.NORTH,
                             leave_button,
                             15,
                             SpringLayout.NORTH,
                             panel)
        layout.putConstraint(SpringLayout.WEST,
                             cancel_button,
                             5,
                             SpringLayout.EAST,
                             leave_button)
        layout.putConstraint(SpringLayout.NORTH,
                             cancel_button,
                             15,
                             SpringLayout.NORTH,
                             panel)
        layout.putConstraint(SpringLayout.EAST,
                             panel,
                             15,
                             SpringLayout.EAST,
                             cancel_button)
        layout.putConstraint(SpringLayout.SOUTH,
                             panel,
                             10,
                             SpringLayout.SOUTH,
                             cancel_button)
        # Add this to NewAtf JFrame
        return panel

    def build_help_label(self, tooltip_text):
        icon = ImageIcon(find_image_resource('smallhelp'))
        label = JLabel()
        label.setIcon(icon)
        label.setToolTipText(tooltip_text)
        return label

    def cancel(self, event):
        self.cancelled = True
        self.dispose()

    def blank(self, event):
        self.controller.show_template()
        self.dispose()

    def create_template(self, event):
        '''
        Put together user selected elements of the template following ATF
        file format.
        '''
        # &-line
        # E.g. &X001001 = JCS 48, 089
        and_line = "{} = {}".format(self.left_field.getText().encode('utf-8'),
                                    self.right_field.getText().encode('utf-8'))

        # Project line
        # E.g. #project: cams/gkab
        # E.g. #project: rimanum
        project_line = "#project: {}".format(
                            self.left_combo.getSelectedItem().encode('utf-8'))
        if self.right_combo.getSelectedItem():
            project_line = "{}/{}".format(
                            project_line,
                            self.right_combo.getSelectedItem().encode('utf-8'))

        # Language line
        # E.g. #atf: lang akk-x-stdbab
        language = self.language_combo.getSelectedItem()
        language_code = self.languages[language]

        # Protocol line/s
        # E.g. #atf: use unicode
        protocols = ''
        for protocol in self.protocols:
            protocols += '#atf: use {}\n'.format(protocol)

        # Put together all lines to create the template and show in ATF area
        self.controller.template = ('{}\n'
                                    '{}\n'
                                    '#atf: lang {}\n'
                                    '{}\n'.format(and_line, project_line,
                                                  language_code, protocols)
                                    )
        self.controller.show_template()
        self.dispose()
开发者ID:oracc,项目名称:nammu,代码行数:104,代码来源:NewAtfView.py

示例10: BurpExtender

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import getSelectedItem [as 别名]

#.........这里部分代码省略.........
        
        importProjButton = JButton("Import",actionPerformed=self.importProj)
        importProjButton.setBounds(470, 10, 100, 30)

        exportProjButton = JButton("Export",actionPerformed=self.exportProj)
        exportProjButton.setBounds(575, 10, 100, 30)

        openProjButton = JButton("Open Directory",actionPerformed=self.openProj)
        openProjButton.setBounds(680, 10, 130, 30)

        currentProjectLabel = JLabel("Current:")
        currentProjectLabel.setBounds(10, 10, 140, 30)

        projects = self.config.options('projects')
        self.currentProject = JComboBox(projects)
        self.currentProject.addActionListener(projectChangeHandler(self))
        self.currentProject.setBounds(140, 10, 140, 30)

        self.autoSave = JCheckBox("Auto Save Mode")
        self.autoSave.setEnabled(False)  # implement this feature
        self.autoSave.setBounds(300, 10, 140, 30)
        self.autoSave.setToolTipText("Will save any changed value while focus is out")

        addProjButton = JButton("Add / Update",actionPerformed=self.addProj)
        addProjButton.setBounds(10, 330, 150, 30)

        removeProjButton = JButton("Remove Current",actionPerformed=self.rmProj)
        removeProjButton.setBounds(315, 330, 146, 30)

        generalOptions = self.config.options('general')
        if 'default project' in generalOptions:
            defaultProj = self.config.get('general','default project')
            self.currentProject.getModel().setSelectedItem(defaultProj)
            self.projPath.setText(self.config.get('projects',self.currentProject.getSelectedItem()))

        self.clearProjTab = True
        self.projectSettings = JPanel()
        self.projectSettings.setBounds(0, 0, 1000, 1000)
        self.projectSettings.setLayout(None)
        self.projectSettings.add(reportLabel)
        self.projectSettings.add(detailsLabel)
        self.projectSettings.add(projPathLabel)
        self.projectSettings.add(addProjButton)
        self.projectSettings.add(openProjButton)
        self.projectSettings.add(projNameLabel)
        self.projectSettings.add(projDetailsScroll)
        self.projectSettings.add(importProjButton)
        self.projectSettings.add(exportProjButton)
        self.projectSettings.add(removeProjButton)
        self.projectSettings.add(generateReportButton)
        self.projectSettings.add(chooseProjPathButton)
        self.projectSettings.add(currentProjectLabel)
        self.projectSettings.add(self.projPath)
        self.projectSettings.add(self.autoSave)
        self.projectSettings.add(self.projName)
        self.projectSettings.add(self.reportType)
        self.projectSettings.add(self.currentProject)

    def initTabs(self):
        #
        ##  init autorize tabs
        #
        
        self._splitpane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT)
        self.scrollPane = JScrollPane(self.logTable)
        self._splitpane.setLeftComponent(self.scrollPane)
开发者ID:anhnt4288,项目名称:PT-Manager,代码行数:70,代码来源:PTManager.py

示例11: __init__

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import getSelectedItem [as 别名]
class NewAccountGUI:
    def __init__(self, amgui):
        self.amgui = amgui
        self.am = amgui.acctmanager
        self.buildgwinfo()
        self.autologin = JCheckBox("Automatically Log In")
        self.acctname = JTextField()
        self.gwoptions = JPanel(doublebuffered)
        self.gwoptions.border = TitledBorder("Gateway Options")
        self.buildgwoptions("Twisted")
        self.mainframe = JFrame("New Account Window")
        self.buildpane()

    def buildgwinfo(self):
        self.gateways = {
            "Twisted": {
                "ident": JTextField(),
                "passwd": JPasswordField(),
                "host": JTextField("twistedmatrix.com"),
                "port": JTextField("8787"),
                "service": JTextField("twisted.words"),
                "persp": JTextField(),
            },
            "AIM": {
                "ident": JTextField(),
                "passwd": JPasswordField(),
                "host": JTextField("toc.oscar.aol.com"),
                "port": JTextField("9898"),
            },
            "IRC": {
                "ident": JTextField(),
                "passwd": JPasswordField(),
                "host": JTextField(),
                "port": JTextField("6667"),
                "channels": JTextField(),
            },
        }
        self.displayorder = {
            "Twisted": [
                ["Identity Name", "ident"],
                ["Password", "passwd"],
                ["Host", "host"],
                ["Port", "port"],
                ["Service Name", "service"],
                ["Perspective Name", "persp"],
            ],
            "AIM": [["Screen Name", "ident"], ["Password", "passwd"], ["Host", "host"], ["Port", "port"]],
            "IRC": [
                ["Nickname", "ident"],
                ["Password", "passwd"],
                ["Host", "host"],
                ["Port", "port"],
                ["Channels", "channels"],
            ],
        }

    def buildgwoptions(self, gw):
        self.gwoptions.removeAll()
        self.gwoptions.layout = GridLayout(len(self.gateways[gw]), 2)
        for mapping in self.displayorder[gw]:
            self.gwoptions.add(JLabel(mapping[0]))
            self.gwoptions.add(self.gateways[gw][mapping[1]])

    def buildpane(self):
        gw = JPanel(GridLayout(1, 2), doublebuffered)
        gw.add(JLabel("Gateway"))
        self.gwlist = JComboBox(self.gateways.keys())  # , actionPerformed=self.changegw)
        self.gwlist.setSelectedItem("Twisted")
        gw.add(self.gwlist)

        stdoptions = JPanel(GridLayout(2, 2), doublebuffered)
        stdoptions.border = TitledBorder("Standard Options")
        stdoptions.add(JLabel())
        stdoptions.add(self.autologin)
        stdoptions.add(JLabel("Account Name"))
        stdoptions.add(self.acctname)

        buttons = JPanel(FlowLayout(), doublebuffered)
        buttons.add(JButton("OK", actionPerformed=self.addaccount))
        buttons.add(JButton("Cancel", actionPerformed=self.cancel))

        mainpane = self.mainframe.getContentPane()
        mainpane.layout = BoxLayout(mainpane, BoxLayout.Y_AXIS)
        mainpane.add(gw)
        mainpane.add(self.gwoptions)
        mainpane.add(stdoptions)
        mainpane.add(buttons)

    def show(self):
        self.mainframe.setLocation(100, 100)
        self.mainframe.pack()
        self.mainframe.show()

    # actionlisteners
    def changegw(self, ae):
        self.buildgwoptions(self.gwlist.getSelectedItem())
        self.mainframe.pack()
        self.mainframe.show()

    def addaccount(self, ae):
#.........这里部分代码省略.........
开发者ID:galaxysd,项目名称:BitTorrent,代码行数:103,代码来源:jyaccount.py

示例12: __init__

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import getSelectedItem [as 别名]
    def __init__(self, view):
        JPanel.__init__(self)
        self.view = view
        self.background = Color.white
        self.config_panel_height = 60

        mainPanel = JPanel(background=self.background, layout=BorderLayout())
        mainPanel.border = self.RoundedBorder()
        configPanel = JPanel(background=self.background, visible=False)

        self.layout = BorderLayout()
        self.add(mainPanel, BorderLayout.NORTH)
        self.add(configPanel, BorderLayout.SOUTH)

        self.config_button = JButton(Icon.arrowdown, rolloverIcon=ShadedIcon.arrowdown, toolTipText='configure', actionPerformed=self.configure, borderPainted=False, focusPainted=False, contentAreaFilled=False)
        self.add(self.config_button)

        self.configPanel = configPanel

        self.slider = JSlider(0, 1, 0, background=self.background)
        self.slider.snapToTicks = True
        mainPanel.add(self.slider)
        self.slider.addChangeListener(self)

        self.min_time = JLabel(' 0.0000 ', opaque=True, background=self.background)
        self.max_time = JLabel(' 0.0000 ', opaque=True, background=self.background)

        self.left_panel = JPanel(background=self.background)
        self.left_panel.add(JButton(Icon.restart, rolloverIcon=ShadedIcon.restart, toolTipText='restart', actionPerformed=self.start, borderPainted=False, focusPainted=False, contentAreaFilled=False))
        self.left_panel.add(self.min_time)
        self.left_panel.add(JButton(icon=Icon.start, rolloverIcon=ShadedIcon.start, toolTipText='jump to beginning', actionPerformed=lambda x: self.slider.setValue(self.slider.minimum), borderPainted=False, focusPainted=False, contentAreaFilled=False))

        self.right_panel = JPanel(background=self.background)
        self.right_panel.add(JButton(icon=Icon.end, rolloverIcon=ShadedIcon.end, toolTipText='jump to end', actionPerformed=lambda x: self.slider.setValue(self.slider.maximum), borderPainted=False, focusPainted=False, contentAreaFilled=False))
        self.right_panel.add(self.max_time)
        self.playpause_button = JButton(Icon.play, actionPerformed=self.pause, rolloverIcon=ShadedIcon.play, toolTipText='continue', borderPainted=False, focusPainted=False, contentAreaFilled=False)
        self.right_panel.add(self.playpause_button)

        mainPanel.add(self.left_panel, BorderLayout.WEST)
        mainPanel.add(self.right_panel, BorderLayout.EAST)

        pdf = JPanel(layout=BorderLayout(), opaque=False)
        pdf.add(JButton(Icon.pdf, rolloverIcon=ShadedIcon.pdf, toolTipText='save pdf', actionPerformed=self.save_pdf, borderPainted=False, focusPainted=False, contentAreaFilled=False))
        pdf.add(JLabel('pdf', horizontalAlignment=javax.swing.SwingConstants.CENTER), BorderLayout.NORTH)
        pdf.maximumSize = pdf.preferredSize
        configPanel.add(pdf)

        self.data = JPanel(layout=BorderLayout(), opaque=False)
        self.data.add(JButton(Icon.data, rolloverIcon=ShadedIcon.data, toolTipText='examine data', actionPerformed=self.show_data, borderPainted=False, focusPainted=False, contentAreaFilled=False))
        self.data.add(JLabel('data', horizontalAlignment=javax.swing.SwingConstants.CENTER), BorderLayout.NORTH)
        self.data.maximumSize = self.data.preferredSize
        configPanel.add(self.data)

        mode = JPanel(layout=BorderLayout(), opaque=False)
        cb = JComboBox(['default', 'rate', 'direct'])
        if self.view.network.mode in [SimulationMode.DEFAULT, SimulationMode.PRECISE]:
            cb.setSelectedIndex(0)
        elif self.view.network.mode in [SimulationMode.RATE]:
            cb.setSelectedIndex(1)
        elif self.view.network.mode in [SimulationMode.DIRECT, SimulationMode.APPROXIMATE]:
            cb.setSelectedIndex(2)
        cb.addActionListener(self)
        self.mode_combobox = cb
        mode.add(cb)
        mode.add(JLabel('mode'), BorderLayout.NORTH)
        mode.maximumSize = mode.preferredSize
        configPanel.add(mode)

        dt = JPanel(layout=BorderLayout(), opaque=False)
        cb = JComboBox(['0.001', '0.0005', '0.0002', '0.0001'])
        cb.setSelectedIndex(0)
        self.view.dt = float(cb.getSelectedItem())
        cb.addActionListener(self)
        self.dt_combobox = cb
        dt.add(cb)
        dt.add(JLabel('time step'), BorderLayout.NORTH)
        dt.maximumSize = dt.preferredSize
        configPanel.add(dt)

        rate = JPanel(layout=BorderLayout(), opaque=False)
        self.rate_combobox = JComboBox(['fastest', '1x', '0.5x', '0.2x', '0.1x', '0.05x', '0.02x', '0.01x', '0.005x', '0.002x', '0.001x'])
        self.rate_combobox.setSelectedIndex(4)
        self.view.set_target_rate(self.rate_combobox.getSelectedItem())
        self.rate_combobox.addActionListener(self)
        rate.add(self.rate_combobox)
        rate.add(JLabel('speed'), BorderLayout.NORTH)
        rate.maximumSize = rate.preferredSize
        configPanel.add(rate)

        spin1 = JPanel(layout=BorderLayout(), opaque=False)
        self.record_time_spinner = JSpinner(SpinnerNumberModel((self.view.timelog.tick_limit - 1) * self.view.dt, 0.1, 100, 1), stateChanged=self.tick_limit)
        spin1.add(self.record_time_spinner)
        spin1.add(JLabel('recording time'), BorderLayout.NORTH)
        spin1.maximumSize = spin1.preferredSize
        configPanel.add(spin1)

        spin2 = JPanel(layout=BorderLayout(), opaque=False)
        self.filter_spinner = JSpinner(SpinnerNumberModel(self.view.tau_filter, 0, 0.5, 0.01), stateChanged=self.tau_filter)
        spin2.add(self.filter_spinner)
        spin2.add(JLabel('filter'), BorderLayout.NORTH)
#.........这里部分代码省略.........
开发者ID:Elhamahm,项目名称:nengo_1.4,代码行数:103,代码来源:timecontrol.py

示例13: TimeControl

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import getSelectedItem [as 别名]
class TimeControl(JPanel, ChangeListener, ActionListener):
    def __init__(self, view):
        JPanel.__init__(self)
        self.view = view
        self.background = Color.white
        self.config_panel_height = 60

        mainPanel = JPanel(background=self.background, layout=BorderLayout())
        mainPanel.border = self.RoundedBorder()
        configPanel = JPanel(background=self.background, visible=False)

        self.layout = BorderLayout()
        self.add(mainPanel, BorderLayout.NORTH)
        self.add(configPanel, BorderLayout.SOUTH)

        self.config_button = JButton(Icon.arrowdown, rolloverIcon=ShadedIcon.arrowdown, toolTipText='configure', actionPerformed=self.configure, borderPainted=False, focusPainted=False, contentAreaFilled=False)
        self.add(self.config_button)

        self.configPanel = configPanel

        self.slider = JSlider(0, 1, 0, background=self.background)
        self.slider.snapToTicks = True
        mainPanel.add(self.slider)
        self.slider.addChangeListener(self)

        self.min_time = JLabel(' 0.0000 ', opaque=True, background=self.background)
        self.max_time = JLabel(' 0.0000 ', opaque=True, background=self.background)

        self.left_panel = JPanel(background=self.background)
        self.left_panel.add(JButton(Icon.restart, rolloverIcon=ShadedIcon.restart, toolTipText='restart', actionPerformed=self.start, borderPainted=False, focusPainted=False, contentAreaFilled=False))
        self.left_panel.add(self.min_time)
        self.left_panel.add(JButton(icon=Icon.start, rolloverIcon=ShadedIcon.start, toolTipText='jump to beginning', actionPerformed=lambda x: self.slider.setValue(self.slider.minimum), borderPainted=False, focusPainted=False, contentAreaFilled=False))

        self.right_panel = JPanel(background=self.background)
        self.right_panel.add(JButton(icon=Icon.end, rolloverIcon=ShadedIcon.end, toolTipText='jump to end', actionPerformed=lambda x: self.slider.setValue(self.slider.maximum), borderPainted=False, focusPainted=False, contentAreaFilled=False))
        self.right_panel.add(self.max_time)
        self.playpause_button = JButton(Icon.play, actionPerformed=self.pause, rolloverIcon=ShadedIcon.play, toolTipText='continue', borderPainted=False, focusPainted=False, contentAreaFilled=False)
        self.right_panel.add(self.playpause_button)

        mainPanel.add(self.left_panel, BorderLayout.WEST)
        mainPanel.add(self.right_panel, BorderLayout.EAST)

        pdf = JPanel(layout=BorderLayout(), opaque=False)
        pdf.add(JButton(Icon.pdf, rolloverIcon=ShadedIcon.pdf, toolTipText='save pdf', actionPerformed=self.save_pdf, borderPainted=False, focusPainted=False, contentAreaFilled=False))
        pdf.add(JLabel('pdf', horizontalAlignment=javax.swing.SwingConstants.CENTER), BorderLayout.NORTH)
        pdf.maximumSize = pdf.preferredSize
        configPanel.add(pdf)

        self.data = JPanel(layout=BorderLayout(), opaque=False)
        self.data.add(JButton(Icon.data, rolloverIcon=ShadedIcon.data, toolTipText='examine data', actionPerformed=self.show_data, borderPainted=False, focusPainted=False, contentAreaFilled=False))
        self.data.add(JLabel('data', horizontalAlignment=javax.swing.SwingConstants.CENTER), BorderLayout.NORTH)
        self.data.maximumSize = self.data.preferredSize
        configPanel.add(self.data)

        mode = JPanel(layout=BorderLayout(), opaque=False)
        cb = JComboBox(['default', 'rate', 'direct'])
        if self.view.network.mode in [SimulationMode.DEFAULT, SimulationMode.PRECISE]:
            cb.setSelectedIndex(0)
        elif self.view.network.mode in [SimulationMode.RATE]:
            cb.setSelectedIndex(1)
        elif self.view.network.mode in [SimulationMode.DIRECT, SimulationMode.APPROXIMATE]:
            cb.setSelectedIndex(2)
        cb.addActionListener(self)
        self.mode_combobox = cb
        mode.add(cb)
        mode.add(JLabel('mode'), BorderLayout.NORTH)
        mode.maximumSize = mode.preferredSize
        configPanel.add(mode)

        dt = JPanel(layout=BorderLayout(), opaque=False)
        cb = JComboBox(['0.001', '0.0005', '0.0002', '0.0001'])
        cb.setSelectedIndex(0)
        self.view.dt = float(cb.getSelectedItem())
        cb.addActionListener(self)
        self.dt_combobox = cb
        dt.add(cb)
        dt.add(JLabel('time step'), BorderLayout.NORTH)
        dt.maximumSize = dt.preferredSize
        configPanel.add(dt)

        rate = JPanel(layout=BorderLayout(), opaque=False)
        self.rate_combobox = JComboBox(['fastest', '1x', '0.5x', '0.2x', '0.1x', '0.05x', '0.02x', '0.01x', '0.005x', '0.002x', '0.001x'])
        self.rate_combobox.setSelectedIndex(4)
        self.view.set_target_rate(self.rate_combobox.getSelectedItem())
        self.rate_combobox.addActionListener(self)
        rate.add(self.rate_combobox)
        rate.add(JLabel('speed'), BorderLayout.NORTH)
        rate.maximumSize = rate.preferredSize
        configPanel.add(rate)

        spin1 = JPanel(layout=BorderLayout(), opaque=False)
        self.record_time_spinner = JSpinner(SpinnerNumberModel((self.view.timelog.tick_limit - 1) * self.view.dt, 0.1, 100, 1), stateChanged=self.tick_limit)
        spin1.add(self.record_time_spinner)
        spin1.add(JLabel('recording time'), BorderLayout.NORTH)
        spin1.maximumSize = spin1.preferredSize
        configPanel.add(spin1)

        spin2 = JPanel(layout=BorderLayout(), opaque=False)
        self.filter_spinner = JSpinner(SpinnerNumberModel(self.view.tau_filter, 0, 0.5, 0.01), stateChanged=self.tau_filter)
        spin2.add(self.filter_spinner)
#.........这里部分代码省略.........
开发者ID:Elhamahm,项目名称:nengo_1.4,代码行数:103,代码来源:timecontrol.py

示例14: Gui

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import getSelectedItem [as 别名]
class Gui(MouseAdapter):
    IMG_MIN_SIZE = 200
    IMG_MAX_SIZE = 500

    def __init__(self):
        self.pos1 = None
        self.puzzle = None

    def mouseEntered(self, event):
        self.in_canvas = True

    def mouseExited(self, event):
        self.in_canvas = False

    def mouseReleased(self, event):
        if not self.in_canvas or self.puzzle == None:
            return

        width = self.images_dict[0].getWidth()
        height = self.images_dict[0].getHeight()

        def valid_pos(pos):
            return pos >= 0 and pos < self.puzzle.level()

        x = (event.getX() - self.canvas.initial_x) / width
        y = (event.getY() - self.canvas.initial_y) / height

        if not valid_pos(x) or not valid_pos(y):
            return

        pos = Point(x, y)
        if self.pos1 != None: #then is second click
            if self.pos1.equals(pos):
                self.pos1 = None
            else:
                self.play_event(self.pos1.y, self.pos1.x, pos.y, pos.x)
                self.pos1 = None
        else:
            self.pos1 = pos
        self.canvas.set_selected(self.pos1)
        self.canvas.repaint()

    def draw(self):

        try:
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        except:
            pass

        self.images_dict = dict()
        self.canvas = Canvas(self.images_dict, None)
        self.canvas.addMouseListener(self)

        self.frame = JFrame("SimplePyzzle", visible = 1)
        self.frame.setMinimumSize(Dimension(300, 300))
        self.frame.setLocationRelativeTo(None)
        self.generate_button = JButton("Generate Puzzle")
        self.bottom_panel = JPanel()

        self.combo_box_list = [9, 16, 25, 36, 49]
        self.combo_box = JComboBox(self.combo_box_list)

        self.frame.contentPane.add(self.canvas, BorderLayout.CENTER)
        self.frame.contentPane.add(self.bottom_panel, BorderLayout.SOUTH)
        self.bottom_panel.add(self.generate_button, BorderLayout.EAST)
        self.bottom_panel.add(self.combo_box, BorderLayout.WEST)

        self.generate_button.actionPerformed = self.generate_board

        self.frame.setSize(500, 500)
        self.frame.defaultCloseOperation = JFrame.EXIT_ON_CLOSE;
        self.frame.pack()

    def generate_board(self, event):

        chooser = JFileChooser()
        status = chooser.showOpenDialog(self.frame)
        if status != JFileChooser.APPROVE_OPTION:
            return

        imageFile = chooser.getSelectedFile()

        self.puzzle = SimplePyzzle(float(int(self.combo_box.getSelectedItem())))
        self.draw_board()
        self.load_images(imageFile, self.puzzle.level())
        self.canvas.set_puzzle(self.puzzle)
        width = self.images_dict[0].getWidth()
        height = self.images_dict[0].getHeight()
        size = Dimension(width * self.puzzle.level(), height * self.puzzle.level())
        self.frame.setPreferredSize(size)
        self.frame.setSize(size)

    def show_error(self, error):
        JOptionPane.showMessageDialog(self.frame, \
                                    error, \
                                    "Error!", \
                                    JOptionPane.ERROR_MESSAGE)

    def load_images(self, file, length):

#.........这里部分代码省略.........
开发者ID:pythonoob,项目名称:SimplePyzzle,代码行数:103,代码来源:Gui.py

示例15: BurpExtender

# 需要导入模块: from javax.swing import JComboBox [as 别名]
# 或者: from javax.swing.JComboBox import getSelectedItem [as 别名]

#.........这里部分代码省略.........
        return



    def getTabCaption(self):
        return "Generate Finding" 



    def getUiComponent(self):
        return self._mainFrame



    # initiaizes when button is clicked in 'Generate Finding Tab'
    def createScanIssue(self, event):

        print "[!] Finding Detail: "

        print "\t[+] Name:\n\t\t", self.issueNameValue.getText().strip()
        name = self.issueNameValue.getText()
        print "\t[+] Description:\n\t\t", self.issueDetailValue.getText().strip()
        description = self.issueDetailValue.getText()
        print "\t[+] Background:\n\t\t", self.issueBackgroundValue.getText().strip()
        background = self.issueBackgroundValue.getText()
        print "\t[+] Remediation:\n\t\t", self.issueRemediationValue.getText().strip()
        remediation = self.issueRemediationValue.getText()
        print "\t[+] Remediation Background:\n\t\t", self.issueRemBackgroundValue.getText().strip()
        remBackground = self.issueRemBackgroundValue.getText()
        print "\t[+] URL Detail:\n\t\t", self.issueURLValue.getText()
        urlDetail = self.issueURLValue.getText()
        print "\t[+] Port Number:\n\t\t", self.issuePortValue.getText()
        portNumber = self.issuePortValue.getText()
        print "\t[+] Confidence Rating:\n\t\t", self.issueConfidenceValue.getSelectedItem()
        confidenceRating = self.issueConfidenceValue.getSelectedItem()
        print "\t[+] Severity Rating:\n\t\t", self.issueSeverityValue.getSelectedItem()
        severityRating = self.issueSeverityValue.getSelectedItem()
        #print "\t[+] Payload Markers:\n\t\t", self.getSelectionBounds()

        # get highlighted data from request/response tabs in 'Generate Finding'
        #print "[!] Request Selected data:", self._requestViewer.getSelectedData()
        #highRequest = self._requestViewer.getSelectedData()
        #print "converted:", self._helpers.bytesToString(highRequest) 
        #print "[!] Response Selected data:", self._responseViewer.getSelectedData()
        #highResponse = self._responseViewer.getSelectedData()
        #print "converted:", self._helpers.bytesToString(highResponse) 

        # current message is used - should work as long as menu item 'Generate Finding' is not reset or used before finding has been generated.
        requestResponse = self.current_message

        print "\t[+] RequestResponse:\n\t\t", requestResponse
        print "\t[+] Service:\n\t\t", requestResponse.getHttpService()        


        # Collect request and Response Markers...
        #print "[**] Request Bounds: ", self._requestHighlight.getSelectionBounds() 
        requestBounds = self._requestHighlight.getSelectionBounds()
        #print "[**] Response Bounds: ", self._responseHighlight.getSelectionBounds() 
        responseBounds = self._responseHighlight.getSelectionBounds()

        # applyMarkers to request/response
        # callbacks.applyMarkers(requestResponse, None, [array('i', (data[1], data[2]))])
        self.reqMarkers = [requestBounds[0],requestBounds[1]]
        print "\t[+] Request Reporting Markers:\n\t\t", self.reqMarkers
        self.resMarkers = [responseBounds[0],responseBounds[1]]
        print "\t[+] Response Reporting Markers:\n\t\t", self.resMarkers
开发者ID:d453d2,项目名称:Generate-Finding,代码行数:70,代码来源:generateFinding.py


注:本文中的javax.swing.JComboBox.getSelectedItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。