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


Python swing.JButton类代码示例

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


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

示例1: tree

def tree():
  """
  tree(xmlfile="dsm2.xml")
    creates a tree view on a given xml file of dsm2 input data
  """
  tv = TreeViewer()
  mp2 = JPanel()
  mp2.setLayout(BorderLayout())
  tf = JTextField("dsm2.inp")
  pb = JButton("parse")
  mp2.add(tf,BorderLayout.CENTER)
  mp2.add(pb,BorderLayout.EAST)
  class ParseListener(ActionListener):
    def __init__(self,tf,tv,fr):
      self.tf = tf
      self.tv = tv
      self.fr = fr
    def actionPerformed(self,evt):
      dsm2file = self.tf.getText()
      parser = DSM2Parser(dsm2file)
      self.tv.xdoc = parser.dsm2_data.toXml()
      self.fr.getContentPane().add(self.tv.gui(),BorderLayout.CENTER)
      self.fr.pack()
      self.fr.setVisible(1)
  fr = JFrame()
  fr.setTitle("DSM2Tree")
  fr.setLocation(100,100)
  fr.setSize(600,60)
  fr.getContentPane().setLayout(BorderLayout())
  fr.getContentPane().add(mp2,BorderLayout.NORTH)
  al = ParseListener(tf,tv,fr)
  pb.addActionListener(al)
  fr.pack()
  fr.setVisible(1)
开发者ID:GTP-CalLitGUI,项目名称:CalLiteGUI_RW1,代码行数:34,代码来源:dsm2.py

示例2: init

    def init(self):
        global exampleList
        self.thinFont = Font("Dialog", 0, 10)

        self.pane = self.getContentPane()
        self.examples = exampleList.keys()
        self.examples.sort()
        self.exampleSelector = JList(self.examples, valueChanged=self.valueChanged)
        self.exampleSelector.setSelectionMode(ListSelectionModel.SINGLE_SELECTION)
        self.exampleSelector.setLayoutOrientation(JList.VERTICAL)
        self.exampleSelector.setPreferredSize(Dimension(150,500))
        self.exampleSelector.setBackground(Color(0.95, 0.95, 0.98))
        self.exampleSelector.setFont(self.thinFont)

        self.centerPanel = JPanel(BorderLayout())
        self.canvas = GraphCanvas()
        self.canvas.setApplet(self)
        self.buttonRow = JPanel(FlowLayout())
        self.backButton = JButton("<", actionPerformed = self.backAction)
        self.backButton.setFont(self.thinFont)
        self.continueButton = JButton("continue >",
                                      actionPerformed=self.continueAction)
        self.continueButton.setFont(self.thinFont)
        self.scaleGroup = ButtonGroup()
        self.linearButton = JRadioButton("linear scale",
                                         actionPerformed=self.linearAction)
        self.linearButton.setSelected(True)
        self.linearButton.setFont(self.thinFont)
        self.logarithmicButton = JRadioButton("logarithmic scale",
                                      actionPerformed=self.logarithmicAction)
        self.logarithmicButton.setFont(self.thinFont)
        self.aboutButton = JButton("About...",
                                   actionPerformed=self.aboutAction)
        self.aboutButton.setFont(self.thinFont)
        self.scaleGroup.add(self.linearButton)
        self.scaleGroup.add(self.logarithmicButton)
        self.buttonRow.add(self.backButton)
        self.buttonRow.add(self.continueButton)
        self.buttonRow.add(JLabel(" "*5))
        self.buttonRow.add(self.linearButton)
        self.buttonRow.add(self.logarithmicButton)
        self.buttonRow.add(JLabel(" "*20));
        self.buttonRow.add(self.aboutButton)
        self.centerPanel.add(self.canvas, BorderLayout.CENTER)
        self.centerPanel.add(self.buttonRow, BorderLayout.PAGE_END)

        self.helpText = JTextPane()
        self.helpText.setBackground(Color(1.0, 1.0, 0.5))
        self.helpText.setPreferredSize(Dimension(800,80))
        self.helpText.setText(re_sub("[ \\n]+", " ", """
        Please select one of the examples in the list on the left!
        """))
        self.pane.add(self.exampleSelector, BorderLayout.LINE_START)
        self.pane.add(self.centerPanel, BorderLayout.CENTER)
        self.pane.add(self.helpText, BorderLayout.PAGE_END)
        self.graph = None
        self.simulation = None
        self.touched = ""
        self.selected = ""
        self.gfxDriver = None
开发者ID:jecki,项目名称:MetaInductionSim,代码行数:60,代码来源:InductionApplet.py

示例3: __init__

    def __init__(self, frame, what, entries, pingFun):
        JDialog(frame, what)
        self.frame   = frame
        self.entries = entries
        self.pingFun = pingFun
        pane = self.getRootPane().getContentPane()

        self.ent_pane, self.ent_list, self.ent = self.createList(entries)
        pane.add(self.ent_pane, BorderLayout.WEST)

        actionPanel = JPanel()
        actionPanel.setLayout(GridLayout(20, 1))
        self.text = JTextField(20)
        actionPanel.add(self.text)
        change = JButton('Change')
        change.setActionCommand('Change')
        change.addActionListener(self)
        actionPanel.add(change)
        actionPanel.add(JLabel(''))
        quit = JButton('Exit')
        quit.setActionCommand('Exit')
        quit.addActionListener(self)
        actionPanel.add(quit)
        actionPanel.add(JLabel(''))
        pane.add(actionPanel, BorderLayout.CENTER)

        self.pack()
开发者ID:samitha,项目名称:lositan,代码行数:27,代码来源:EditTextList.py

示例4: init

 def init(self):
     jbNew= JButton( LoadDefaultXmlThrottlesLayoutAction() )
     jbNew.setIcon( NamedIcon("resources/Throttles.gif","resources/Throttles.gif") )
     jbNew.addMouseListener(self.getMouseListeners()[0]) # In order to get the popupmenu on the button too
     jbNew.setToolTipText( jbNew.getText() )
     jbNew.setText( None )
     self.add(jbNew)
开发者ID:NomDInet,项目名称:JMRI,代码行数:7,代码来源:Throttles.py

示例5: __init__

    def __init__(self, parent, title, modal, app):
        JDialog.__init__(self, parent, title, modal)

        #Download and Read Dialog
        border = BorderFactory.createEmptyBorder(5, 7, 5, 7)
        self.getContentPane().setBorder(border)
        self.setLayout(BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS))

        panel = JPanel()
        panel.setAlignmentX(0.5)
        panel.setLayout(BoxLayout(panel, BoxLayout.Y_AXIS))
        panel.add(Box.createRigidArea(Dimension(0, 10)))

        self.progressLbl = JLabel(app.strings.getString("downloading_and_reading_errors"))
        panel.add(self.progressLbl)

        panel.add(Box.createRigidArea(Dimension(0, 10)))

        self.progressBar = JProgressBar(0, 100, value=0)
        panel.add(self.progressBar)
        self.add(panel)

        self.add(Box.createRigidArea(Dimension(0, 20)))

        cancelBtn = JButton(app.strings.getString("cancel"),
                            ImageProvider.get("cancel"),
                            actionPerformed=app.on_cancelBtn_clicked)
        cancelBtn.setAlignmentX(0.5)
        self.add(cancelBtn)

        self.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE)
        self.pack()
开发者ID:alex85k,项目名称:qat_script,代码行数:32,代码来源:OtherDialogs.py

示例6: DCCThrottle

class DCCThrottle(Jynstrument, PropertyChangeListener, AddressListener, jmri.ThrottleListener):
    #Jynstrument main and mandatory methods
    def getExpectedContextClassName(self):
        return "jmri.jmrit.throttle.ThrottleWindow"
    
    def init(self):
        self.getContext().addPropertyChangeListener(self) #ThrottleFrame change
        self.addressPanel = self.getContext().getCurrentThrottleFrame().getAddressPanel()
        self.addressPanel.addAddressListener(self) # change of throttle in Current frame
        self.panelThrottle = self.getContext().getCurrentThrottleFrame().getAddressPanel().getThrottle() # the throttle
        self.label = JButton(ImageIcon(self.getFolder() + "/DCCThrottle.png","DCCThrottle")) #label
        self.label.addMouseListener(self.getMouseListeners()[0]) # In order to get the popupmenu on the button too
        self.add(self.label)
        # create a dcc throttle and request one from the ThrottleManager
        self.masterThrottle = None
        if ( jmri.InstanceManager.throttleManagerInstance().requestThrottle(listenToDCCThrottle, self) == False):
            print "Couldn't request a throttle for "+locoAddress        
        # Advanced functions
        self.advFunctions = AdvFunctions()

    def quit(self):
        if (self.masterThrottle != None):
            self.masterThrottle.removePropertyChangeListener(self)
            self.masterThrottle = None
    self.panelThrottle = None
        self.advFunctions = None
        if (self.addressPanel != None):
            self.addressPanel.removeAddressListener(self)
            self.addressPanel = None            
        self.getContext().removePropertyChangeListener(self)               
开发者ID:AndTH,项目名称:JMRI,代码行数:30,代码来源:DCCThrottle.py

示例7: init

 def init(self):
     jbNew = JButton( PaneOpsProgAction() )
     jbNew.setIcon( NamedIcon("resources/decoderpro.gif","resources/decoderpro.gif") )
     jbNew.addMouseListener(self.getMouseListeners()[0]) # In order to get the popupmenu on the button too
     jbNew.setToolTipText( jbNew.getText() )
     jbNew.setText( None )
     self.add(jbNew)
开发者ID:NomDInet,项目名称:JMRI,代码行数:7,代码来源:DecoderPro.py

示例8: add_template

    def add_template(self,name,constructor,image):
        icon = ImageIcon(image)
        if icon.iconWidth>self.max_icon_width:
            icon = ImageIcon(icon.image.getScaledInstance(self.max_icon_width,icon.iconHeight*self.max_icon_width/icon.iconWidth,Image.SCALE_SMOOTH))


        panel = JPanel(layout = BorderLayout(),opaque = False)

        button = JButton(icon = icon,toolTipText = name.replace('\n',' '),
                       borderPainted = False,focusPainted = False,contentAreaFilled = False,margin = java.awt.Insets(0,0,0,0),
                       verticalTextPosition = AbstractButton.BOTTOM,horizontalTextPosition = AbstractButton.CENTER,
                       mousePressed = lambda e: e.source.transferHandler.exportAsDrag(e.source,e,TransferHandler.COPY))
        button.transferHandler = self
        panel.add(button)

        text = '<html><center>%s</center></html>'%name.replace('\n','<br/>')
        label = JLabel(text,horizontalAlignment = SwingConstants.CENTER,foreground = Color.WHITE)
        self.labels.append(label)
        panel.add(label,BorderLayout.SOUTH)
        self.panels.append(panel)

        panel.alignmentY = Component.CENTER_ALIGNMENT
        panel.border = BorderFactory.createEmptyBorder(2,1,2,1)
        panel.maximumSize = panel.preferredSize
        self.panel.add(panel)
        self.templates[button] = constructor
开发者ID:Elhamahm,项目名称:nengo_1.4,代码行数:26,代码来源:template.py

示例9: handle

 def handle(self):
     print 'connection from', self.client_address
     conn = self.request
     while 1:
         msg = conn.recv(20)
         if msg == "keymap":
             print "keymapping!"
             keymapFrame = JFrame('Key Mapping Configuration',
                            defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
                            size = (300, 500)
                            )
             keyButton = JButton('Press any key in iPhone')
             keymapFrame.add(keyButton)
             keymapFrame.visible = True
             while 1:
                 recvKey = conn.recv(20)
                 keyButton.setLabel("%s?" % recvKey)
                 keyInput = raw_input()
                 keynum[recvKey] = keyInput
                 keyButton.setText('Press any key in iPhone')
                 if recvKey == "keymap":
                     keymapFrame.visible = False
                     break
         if msg == "quit()":
             conn.close()
             print self.client_address, 'disconnected'
             break
         print self.client_address, msg
开发者ID:jooneyp,项目名称:PhoyStick,代码行数:28,代码来源:keyListener.py

示例10: __init__

    def __init__(self, frame, chart, pingFun):
        JDialog(frame)
        self.setTitle("Chart Settings")
        self.setModal(True)
        self.pingFun = pingFun
        pane = self.getRootPane().getContentPane()
        pane.setLayout(GridLayout(7, 2))
        pane.add(JLabel("Marker color"))
        self.markerPanel = self.createColorPanel(chart.markerColor, pane)
        pane.add(JLabel("Positive selection color"))
        self.posPanel = self.createColorPanel(chart.posColor, pane)
        pane.add(JLabel("Neutral color"))
        self.neuPanel = self.createColorPanel(chart.neuColor, pane)
        pane.add(JLabel("Balancing selection color "))
        self.balPanel = self.createColorPanel(chart.balColor, pane)

        self.add(JLabel("Label candidate selected loci"))
        self.selLabel = JCheckBox()
        self.selLabel.setSelected(chart.labelSelected)
        self.add(self.selLabel)
        self.add(JLabel("Label candidate neutral loci"))
        self.neuLabel = JCheckBox()
        self.neuLabel.setSelected(chart.labelNeutral)
        self.add(self.neuLabel)

        change = JButton("Change")
        change.setActionCommand("Change")
        change.addActionListener(self)
        pane.add(change)
        exit = JButton("Exit")
        exit.setActionCommand("Exit")
        exit.addActionListener(self)
        pane.add(exit)
        self.pack()
开发者ID:tiagoantao,项目名称:lositan,代码行数:34,代码来源:ChartConf.py

示例11: getControlPanel

def getControlPanel():
    global controlPanel
    controlPanel = JPanel()
    controlPanel.setLayout(BoxLayout(controlPanel, BoxLayout.Y_AXIS))
    for row in keyLayout:
        rowPanel = JPanel()
        rowPanel.setLayout(BoxLayout(rowPanel, BoxLayout.X_AXIS))
        controlPanel.add(rowPanel)
        for key in row:
            button = JButton(key[0], actionPerformed=handleKeyButton)
            button.setActionCommand(key[1])
            rowPanel.add(button)

    global terminalResult
    terminalResult = JTextArea()
    scroller = JScrollPane(terminalResult)
    terminalResult.setLineWrap(True)
    scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS)
    scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER)
    controlPanel.add(scroller)

    global terminalInput
    termInputPanel = JPanel()
    termInputPanel.setLayout(BoxLayout(termInputPanel, BoxLayout.X_AXIS))
    termInputLabel = JLabel("Command")
    termInputPanel.add(termInputLabel)
    terminalInput = JTextField(actionPerformed=handleTerminalInput)
    minimumSize = terminalInput.getMinimumSize()
    maximumSize = terminalInput.getMaximumSize()
    terminalInput.setMaximumSize(Dimension(maximumSize.width, minimumSize.height))

    termInputPanel.add(terminalInput)
    controlPanel.add(termInputPanel)

    return controlPanel
开发者ID:sjp38,项目名称:ash,代码行数:35,代码来源:ashdi.py

示例12: add_button

 def add_button(self, text, action):
     index = len(self.actions)
     name = "button%i" % index
     button = JButton(text)
     self.panel.add(button)
     button.setActionCommand(name)
     button.addActionListener(self)
     self.actions[name] = action
     return button
开发者ID:Serabe,项目名称:geogebra,代码行数:9,代码来源:algo.py

示例13: make_button

def make_button(label, tooltip_text, icon_file_path=None):
    """Returns a JButton"""
    button = JButton()
    button.actionCommand = label
    button.toolTipText = tooltip_text
    if icon_file_path:
        button.icon = ImageIcon(icon_file_path, tooltip_text.upper())
    else:
        button.text = label
    return button
开发者ID:bgr,项目名称:unnamed_gui_tool,代码行数:10,代码来源:javautils.py

示例14: loadPanel

    def loadPanel(self):
        panel = JPanel()

        panel.setLayout(BoxLayout(panel, BoxLayout.Y_AXIS))

        bottomButtonBarPanel = JPanel()
        bottomButtonBarPanel.setLayout(BoxLayout(bottomButtonBarPanel, BoxLayout.X_AXIS))
        bottomButtonBarPanel.setAlignmentX(1.0)

        self.runButton = JButton("Run", actionPerformed=self.start)
        self.cancelButton = JButton("Close", actionPerformed=self.cancel)

        bottomButtonBarPanel.add(Box.createHorizontalGlue());
        bottomButtonBarPanel.add(self.runButton)
        bottomButtonBarPanel.add(self.cancelButton)

        # Dimension(width,height)    
        bottom = JPanel()
        bottom.setLayout(BoxLayout(bottom, BoxLayout.X_AXIS))
        bottom.setAlignmentX(1.0)

        self.progressBar = JProgressBar()
        self.progressBar.setIndeterminate(False)
        self.progressBar.setMaximum(100)
        self.progressBar.setValue(0)

        bottom.add(self.progressBar)

        self.statusTextArea = JTextArea()
        self.statusTextArea.setEditable(False)
        scrollPane = JScrollPane(self.statusTextArea)
        scrollPanel = JPanel()
        scrollPanel.setLayout(BoxLayout(scrollPanel, BoxLayout.X_AXIS))
        scrollPanel.setAlignmentX(1.0)
        scrollPanel.add(scrollPane)

        panel.add(scrollPanel)
        panel.add(bottomButtonBarPanel)
        panel.add(bottom)

        self.add(panel)
        self.setTitle("Determine Session Cookie(s)")
        self.setSize(450, 300)
        self.setLocationRelativeTo(None)
        self.setVisible(True)


        original_request_bytes = self.selected_message.getRequest()
        http_service = self.selected_message.getHttpService()
        helpers = self.callbacks.getHelpers()
        request_info = helpers.analyzeRequest(http_service, original_request_bytes)
        parameters = request_info.getParameters();
        cookie_parameters = [parameter for parameter in parameters if parameter.getType() == IParameter.PARAM_COOKIE]
        num_requests_needed = len(cookie_parameters) + 2
        self.statusTextArea.append("This may require up to " + str(num_requests_needed) + " requests to be made. Hit 'Run' to begin.\n")
开发者ID:gheld,项目名称:burp-g2plugins,代码行数:55,代码来源:G2DetermineSessionCookie.py

示例15: initConfigurationTab

    def initConfigurationTab(self):
        #
        ##  init configuration tab
        #
        self.prevent304 = JCheckBox("Prevent 304 Not Modified status code")
        self.prevent304.setBounds(290, 25, 300, 30)

        self.ignore304 = JCheckBox("Ignore 304/204 status code responses")
        self.ignore304.setBounds(290, 5, 300, 30)
        self.ignore304.setSelected(True)

        self.autoScroll = JCheckBox("Auto Scroll")
        #self.autoScroll.setBounds(290, 45, 140, 30)
        self.autoScroll.setBounds(160, 40, 140, 30)

        self.doUnauthorizedRequest = JCheckBox("Check unauthenticated")
        self.doUnauthorizedRequest.setBounds(290, 45, 300, 30)
        self.doUnauthorizedRequest.setSelected(True)

        startLabel = JLabel("Authorization checks:")
        startLabel.setBounds(10, 10, 140, 30)
        self.startButton = JButton("Autorize is off",actionPerformed=self.startOrStop)
        self.startButton.setBounds(160, 10, 120, 30)
        self.startButton.setBackground(Color(255, 100, 91, 255))

        self.clearButton = JButton("Clear List",actionPerformed=self.clearList)
        self.clearButton.setBounds(10, 40, 100, 30)

        self.replaceString = JTextArea("Cookie: Insert=injected; header=here;", 5, 30)
        self.replaceString.setWrapStyleWord(True);
        self.replaceString.setLineWrap(True)
        self.replaceString.setBounds(10, 80, 470, 180)

        self.filtersTabs = JTabbedPane()
        self.filtersTabs.addTab("Enforcement Detector", self.EDPnl)
        self.filtersTabs.addTab("Detector Unauthenticated", self.EDPnlUnauth)
        self.filtersTabs.addTab("Interception Filters", self.filtersPnl)
        self.filtersTabs.addTab("Export", self.exportPnl)

        self.filtersTabs.setBounds(0, 280, 2000, 700)

        self.pnl = JPanel()
        self.pnl.setBounds(0, 0, 1000, 1000);
        self.pnl.setLayout(None);
        self.pnl.add(self.startButton)
        self.pnl.add(self.clearButton)
        self.pnl.add(self.replaceString)
        self.pnl.add(startLabel)
        self.pnl.add(self.autoScroll)
        self.pnl.add(self.ignore304)
        self.pnl.add(self.prevent304)
        self.pnl.add(self.doUnauthorizedRequest)
        self.pnl.add(self.filtersTabs)
开发者ID:federicodotta,项目名称:Autorize,代码行数:53,代码来源:Autorize.py


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