Python javax.swing.JButton() Examples

The following are 10 code examples of javax.swing.JButton(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module javax.swing , or try the search function .
Example #1
Source File: tracer.py    From burp-tracer with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, extender):
        # Initialize self
        super(ActionsPanel, self).__init__()
        self.extender = extender
        self.setLayout(GridLayout(2, 1))
        # Create children
        self.title = JLabel('Actions')
        self.actions = JPanel(GridLayout(1, 3))
        self.start = JButton('Start')
        self.info = JButton('Info')
        # Configure children
        self.title.setFont(Fonts.Heading)
        self.title.setForeground(Colors.Orange)
        self.actions.layout.vgap = 0
        self.actions.layout.hgap = 0
        self.start.addActionListener(StartActionListener(extender))
        self.info.addActionListener(InfoActionListener(extender))
        # Add children
        self.add(self.title)
        self.add(self.actions)
        self.actions.add(self.start)
        self.actions.add(self.info) 
Example #2
Source File: burp_git_bridge.py    From burp-git-bridge with MIT License 5 votes vote down vote up
def __init__(self, callbacks, log):
        self.callbacks = callbacks
        self.log = log
        self.log_table = None # to be set by caller

        self.setLayout(BoxLayout(self, BoxLayout.PAGE_AXIS))

        label = JLabel("Reload from Git Repo:")
        button = JButton("Reload")
        button.addActionListener(CommandPanel.ReloadAction(log))
        self.add(label)
        self.add(button)

        label = JLabel("Send selected entries to respective Burp tools:")
        button = JButton("Send")
        button.addActionListener(CommandPanel.SendAction(self))
        self.add(label)
        self.add(button)

        label = JLabel("Remove selected entries from Git Repo:")
        button = JButton("Remove")
        button.addActionListener(CommandPanel.RemoveAction(self, log))
        self.add(label)
        self.add(button)

        # TODO: maybe add a git command box 
Example #3
Source File: typedef_editor.py    From blackboxprotobuf with MIT License 5 votes vote down vote up
def createButton(self, text, command):
        """Generate a new button with a given text and command"""
        button = JButton(text)
        button.setAlignmentX(Component.CENTER_ALIGNMENT)
        button.setActionCommand(command)
        button.addActionListener(self._button_listener)
        return button 
Example #4
Source File: typedef_tab.py    From blackboxprotobuf with MIT License 5 votes vote down vote up
def createButton(self, text, command):
        """Generate new button with the given text and command string"""
        button = JButton(text)
        button.setAlignmentX(Component.CENTER_ALIGNMENT)
        button.setActionCommand(command)
        button.addActionListener(self._button_listener)
        return button 
Example #5
Source File: editor.py    From blackboxprotobuf with MIT License 5 votes vote down vote up
def createButton(self, text, command):
        """Create a new button with the given text and command"""
        button = JButton(text)
        button.setAlignmentX(Component.CENTER_ALIGNMENT)
        button.setActionCommand(command)
        button.addActionListener(self._button_listener)
        return button 
Example #6
Source File: test_jbasic.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_java_bean_properties(self):

        b1 = swing.JButton()
        b1.label = 'foo'
        b2 = swing.JButton(label='foo')
        self.assertEquals(b1.label, b2.label)
        self.assertEquals(b1.label, 'foo')

        # Test bean event properties - single and multiple
        def testAction(event):
            JythonBasicTests.flag += 1

        doit = ActionEvent(b1, ActionEvent.ACTION_PERFORMED, "")

        b1.actionPerformed = testAction
        JythonBasicTests.flag = 0
        b1.doClick()
        self.assertEquals(
            JythonBasicTests.flag, 1,
            'expected one action per event but got %s' % JythonBasicTests.flag)

        b1.actionPerformed.append(testAction)
        JythonBasicTests.flag = 0
        b1.doClick()
        self.assertEquals(JythonBasicTests.flag, 2, 'two actions per event')

        b1.actionPerformed = testAction
        JythonBasicTests.flag = 0
        b1.doClick()
        self.assertEquals(JythonBasicTests.flag, 1,
                          'one actions per event - again') 
Example #7
Source File: test_jbasic.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_java_bean_properties(self):

        b1 = swing.JButton()
        b1.label = 'foo'
        b2 = swing.JButton(label='foo')
        self.assertEquals(b1.label, b2.label)
        self.assertEquals(b1.label, 'foo')

        # Test bean event properties - single and multiple
        def testAction(event):
            JythonBasicTests.flag += 1

        doit = ActionEvent(b1, ActionEvent.ACTION_PERFORMED, "")

        b1.actionPerformed = testAction
        JythonBasicTests.flag = 0
        b1.doClick()
        self.assertEquals(
            JythonBasicTests.flag, 1,
            'expected one action per event but got %s' % JythonBasicTests.flag)

        b1.actionPerformed.append(testAction)
        JythonBasicTests.flag = 0
        b1.doClick()
        self.assertEquals(JythonBasicTests.flag, 2, 'two actions per event')

        b1.actionPerformed = testAction
        JythonBasicTests.flag = 0
        b1.doClick()
        self.assertEquals(JythonBasicTests.flag, 1,
                          'one actions per event - again') 
Example #8
Source File: omnibar.py    From inql with Apache License 2.0 4 votes vote down vote up
def __init__(self, hint=None, label=None, action=None):
        if not hint: hint = 'Omnibar hint'
        if not label: label = 'Run'
        if not action: action = nop_evt
        self.this = JPanel()
        self.this.setLayout(BorderLayout())

        # Add an hinttextfield
        self._text = _HintTextField(hint, action)
        self.this.add(BorderLayout.CENTER, self._text.this)

        # Add a run buttpn
        button = JButton(label)
        button.addActionListener(action)
        self.this.add(BorderLayout.EAST, button) 
Example #9
Source File: main.py    From aws-extender with MIT License 3 votes vote down vote up
def build_gui(self):
        """Construct GUI elements."""
        panel = JPanel(BorderLayout(3, 3))
        panel.setBorder(EmptyBorder(160, 160, 160, 160))

        self.aws_access_key_inpt = JTextField(10)
        self.aws_secret_key_inpt = JTextField(10)
        self.aws_session_token_inpt = JTextField(10)
        self.gs_access_key_inpt = JTextField(10)
        self.gs_secret_key_inpt = JTextField(10)
        self.wordlist_path_inpt = JTextField(10)
        self.passive_mode = JCheckBox('Enabled')
        self.ssl_verification = JCheckBox('Enabled')

        save_btn = JButton('Save', actionPerformed=self.save_config)

        labels = JPanel(GridLayout(0, 1))
        inputs = JPanel(GridLayout(0, 1))
        panel.add(labels, BorderLayout.WEST)
        panel.add(inputs, BorderLayout.CENTER)

        top_label = JLabel('<html><b>Settings</b><br><br></html>')
        top_label.setHorizontalAlignment(JLabel.CENTER)
        panel.add(top_label, BorderLayout.NORTH)
        labels.add(JLabel('AWS Access Key:'))
        inputs.add(self.aws_access_key_inpt)
        labels.add(JLabel('AWS Secret Key:'))
        inputs.add(self.aws_secret_key_inpt)
        labels.add(JLabel('AWS Session Key (optional):'))
        inputs.add(self.aws_session_token_inpt)
        labels.add(JLabel('GS Access Key:'))
        inputs.add(self.gs_access_key_inpt)
        labels.add(JLabel('GS Secret Key:'))
        inputs.add(self.gs_secret_key_inpt)
        labels.add(JLabel('Wordlist Filepath (optional):'))
        inputs.add(self.wordlist_path_inpt)
        labels.add(JLabel('Passive Mode:'))
        inputs.add(self.passive_mode)
        labels.add(JLabel('SSL Verification:'))
        inputs.add(self.ssl_verification)
        panel.add(save_btn, BorderLayout.SOUTH)
        return panel 
Example #10
Source File: FransLinkfinder.py    From BurpJSLinkFinder with MIT License 3 votes vote down vote up
def initUI(self):
        self.tab = swing.JPanel()

        # UI for Output
        self.outputLabel = swing.JLabel("LinkFinder Log:")
        self.outputLabel.setFont(Font("Tahoma", Font.BOLD, 14))
        self.outputLabel.setForeground(Color(255,102,52))
        self.logPane = swing.JScrollPane()
        self.outputTxtArea = swing.JTextArea()
        self.outputTxtArea.setFont(Font("Consolas", Font.PLAIN, 12))
        self.outputTxtArea.setLineWrap(True)
        self.logPane.setViewportView(self.outputTxtArea)
        self.clearBtn = swing.JButton("Clear Log", actionPerformed=self.clearLog)
        self.exportBtn = swing.JButton("Export Log", actionPerformed=self.exportLog)
        self.parentFrm = swing.JFileChooser()



        # Layout
        layout = swing.GroupLayout(self.tab)
        layout.setAutoCreateGaps(True)
        layout.setAutoCreateContainerGaps(True)
        self.tab.setLayout(layout)
      
        layout.setHorizontalGroup(
            layout.createParallelGroup()
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup()
                    .addComponent(self.outputLabel)
                    .addComponent(self.logPane)
                    .addComponent(self.clearBtn)
                    .addComponent(self.exportBtn)
                )
            )
        )
        
        layout.setVerticalGroup(
            layout.createParallelGroup()
            .addGroup(layout.createParallelGroup()
                .addGroup(layout.createSequentialGroup()
                    .addComponent(self.outputLabel)
                    .addComponent(self.logPane)
                    .addComponent(self.clearBtn)
                    .addComponent(self.exportBtn)
                )
            )
        )