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)
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)
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()
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
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
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)
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()
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()
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
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)
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
def _prepare_components(self, values): self._text_field = JTextField() self._text_field.setColumns(30) self._text_field.setEditable(False) self._text_field.setText(values['database_path']) self.add(self._text_field) button = JButton('Save as...') button.addActionListener(self) self.add(button)
def __init__(self): self.listeners = EventListenerList() self.close_button = JButton(actionPerformed=self._clicked) self.close_button.setText(unichr(0x00d7)) # multiplication sign self.close_button.border = None self.close_button.contentAreaFilled = False self.close_button.addMouseListener(TabComponentCloseableMixin.EventListener(self)) self.add(self.close_button) super(TabComponentCloseableMixin, self).__init__()
def build_buttons_panel(self): ''' Builds the buttons panel to save or cancel changes. TODO: Reset button to reset to defaults? ''' panel = JPanel(FlowLayout()) panel.add(JButton('Cancel', actionPerformed=self.cancel)) panel.add(JButton('Save', actionPerformed=self.save)) return panel
def callBoss(self, event): self.chatWindow = swing.JFrame("Incoming message!") newPanel = JPanel(GridLayout()) self.chatWindow.add(newPanel) newPanel.add(swing.JLabel("New message from The Boss. Accept?")) newPanel.add(JButton("Yes", actionPerformed=self.launchChatIn)) newPanel.add(JButton("No", actionPerformed=self.hide)) self.chatWindow.pack() self.chatWindow.show()
def getUiComponent(self): self.HaEPanel = JPanel() self.HaEPanel.setBorder(None) self.HaEPanel.setLayout(BorderLayout(0, 0)) self.panel = JPanel() self.HaEPanel.add(self.panel, BorderLayout.NORTH) self.panel.setLayout(BorderLayout(0, 0)) self.tabbedPane = JTabbedPane(JTabbedPane.TOP) self.panel.add(self.tabbedPane, BorderLayout.CENTER) self.setPanel = JPanel() self.tabbedPane.addTab("Set", None, self.setPanel, None) self.setPanel.setLayout(BorderLayout(0, 0)) self.setPanel_1 = JPanel() self.setPanel.add(self.setPanel_1, BorderLayout.NORTH) self.nameString = JLabel("Name") self.setPanel_1.add(self.nameString) self.nameTextField = JTextField() self.setPanel_1.add(self.nameTextField) self.nameTextField.setColumns(10) self.regexString = JLabel("Regex") self.setPanel_1.add(self.regexString) self.regexTextField = JTextField() self.setPanel_1.add(self.regexTextField) self.regexTextField.setColumns(10) self.extractCheckBox = JCheckBox("Extract") self.setPanel_1.add(self.extractCheckBox) self.highlightCheckBox = JCheckBox("Highlight") self.setPanel_1.add(self.highlightCheckBox) self.setPanel_2 = JPanel() self.setPanel.add(self.setPanel_2) self.colorString = JLabel("Color") self.setPanel_2.add(self.colorString) self.colorTextField = JTextField() self.setPanel_2.add(self.colorTextField) self.colorTextField.setColumns(5) self.addBottun = JButton("Add", actionPerformed=self.addConfig) self.setPanel_2.add(self.addBottun) self.tipString = JLabel("") self.setPanel_2.add(self.tipString) self.configPanel = JPanel() self.tabbedPane.addTab("Config", None, self.configPanel, None) self.configPanel.setLayout(BorderLayout(0, 0)) self.configString = JLabel("This is config file content.") self.configString.setHorizontalAlignment(SwingConstants.CENTER) self.configPanel.add(self.configString, BorderLayout.NORTH) self.configTextArea = JTextArea() self.configTextArea.setEnabled(False) self.configTextArea.setTabSize(4) self.configTextArea.setLineWrap(True) self.configTextArea.setRows(20) self.configPanel.add(self.configTextArea, BorderLayout.SOUTH) self.scrollPane = JScrollPane(self.configTextArea) self.configPanel.add(self.scrollPane, BorderLayout.SOUTH) self.reloadButton = JButton("Reload", actionPerformed=self.reloadConfig) self.configPanel.add(self.reloadButton, BorderLayout.CENTER) return self.HaEPanel
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
def __init__(self, button=None): super(ConfigPanel.SetKey, self).__init__() self.setTitle('Enter version label') self.setModal(True) if button is None: self.button = JButton() else: self.button = button self.initUI()
def getButton(self, label, positionX, positionY): """ Creates a JButton with a specific label and position """ button = JButton(label) button.setBounds(positionX, positionY, self.BUTTON_WIDTH, self.BUTTON_HEIGHT) return button
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)
def __init__(self): # constructor # origing of coordinates self.coordx = 10 self.coordy = 10 # inintialize values self.Canvas = None self.default_naming = 'MouseID_ExperimentalGroup_slide-X' # create panel (what is inside the GUI) self.panel = self.getContentPane() self.panel.setLayout(GridLayout(8, 2)) self.setTitle('Subdividing ROIs') # define buttons here: self.subimage_number = DefaultListModel() mylist = JList(self.subimage_number, valueChanged=self.open_lowres_image) # mylist.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); mylist.setLayoutOrientation(JList.VERTICAL) mylist.setVisibleRowCount(1) listScroller1 = JScrollPane(mylist) listScroller1.setPreferredSize(Dimension(200, 90)) quitButton = JButton("Quit", actionPerformed=self.quit) selectInputFolderButton = JButton("Select Input", actionPerformed=self.select_input) cubifyROIButton = JButton("Cubify ROI", actionPerformed=self.cubify_ROI) saveButton = JButton("Save ROIs", actionPerformed=self.save_ROIs) self.textfield1 = JTextField('18') self.textfield2 = JTextField(self.default_naming) self.textfield3 = JTextField('R-Tail') self.textfield4 = JTextField('6, 4, 22.619') self.textfield5 = JTextField('0') # add buttons here self.panel.add(Label("Name your image, or use filename")) self.panel.add(self.textfield2) self.panel.add(selectInputFolderButton) self.panel.add(listScroller1) self.panel.add(Label("Adjust the size of the squared ROIs")) self.panel.add(self.textfield1) self.panel.add(Label("give a name of your hand-drawn ROI")) self.panel.add(self.textfield3) self.panel.add(Label("For ARA: piram, ch, res")) # piramid number (high to low), channel number, final resolution (um/px)")) self.panel.add(self.textfield4) self.panel.add(Label("Piramid to check (0:none; 1:highest)")) self.panel.add(self.textfield5) self.panel.add(cubifyROIButton) self.panel.add(saveButton) self.panel.add(quitButton) # other stuff to improve the look self.pack() # packs the frame self.setVisible(True) # shows the JFrame self.setLocation(self.coordx, self.coordy)
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
def __init__(self): self.frame = JFrame('StopWatch', defaultCloseOperation=JFrame.EXIT_ON_CLOSE) self.start = JButton('Start', actionPerformed=self.start) self.frame.add(self.start, BorderLayout.WEST) self.stop = JButton('Stop', actionPerformed=self.stop) self.frame.add(self.stop, BorderLayout.EAST) self.label = JLabel(' ' * 45) self.frame.add(self.label, BorderLayout.SOUTH) self.frame.pack()
def run(self): frame = JFrame('SplitPane6', defaultCloseOperation=JFrame.EXIT_ON_CLOSE) frame.add( JSplitPane(JSplitPane.HORIZONTAL_SPLIT, JButton('Left'), JButton('Right'), oneTouchExpandable=1)) frame.pack() frame.setVisible(1)
def __init__(self, spy, parentCrate=None): JButton.__init__(self) self.spy = spy self.parentCrate = parentCrate self.text = "0" self.icon = self.redLED self.addActionListener(self) self.margin = Insets(1, 1, 1, 1) self.focusPainted = 0 self.borderPainted = 0
def run(self): self.frame = frame = JFrame('SimpleDialog', size=(250, 100), layout=GridLayout(0, 2), locationRelativeTo=None, defaultCloseOperation=JFrame.EXIT_ON_CLOSE) frame.add(JButton('Modal', actionPerformed=self.makeDialog)) frame.add(JButton('non-Modal', actionPerformed=self.makeDialog)) self.boxNum = 0 frame.setVisible(1)
def tab_ui(self): self.panel = JPanel() self.panel.setLayout(None) self.ui_client_dnslog_label_1 = JLabel('-' * 10 + u' IP伪造请求头 & DNSLog 配置 ' + '-' * 155) self.ui_client_dnslog_label_1.setBounds(20, 10, 1000, 28) self.ui_client_ip_label_1 = JLabel(u'伪造IP: ') self.ui_client_ip_label_1.setBounds(20, 40, 70, 30) self.ui_client_ip = JTextField('127.0.0.1') self.ui_client_ip.setBounds(80, 40, 200, 28) self.ui_client_url_label_1 = JLabel(u'dnslog url: ') self.ui_client_url_label_1.setBounds(10, 80, 70, 30) self.ui_client_url = JTextField('http://examlpe.com') self.ui_client_url.setBounds(80, 80, 200, 28) self.ui_button_label = JLabel('-' * 210) self.ui_button_label.setBounds(20, 110, 1000, 28) #self.ui_web_test_button = JButton(u'登录测试', actionPerformed=self.login_test) #self.ui_web_test_button.setBounds(20, 140, 100, 28) self.ui_save_button = JButton(u'保存配置', actionPerformed=self.save_configuration) self.ui_save_button.setBounds(20, 140, 100, 28) self.ui_debug_button = JButton('Debug', actionPerformed=self.debug_fun) self.ui_debug_button.setBounds(135, 140, 100, 28) self.panel.add(self.ui_debug_button) self.ui_log_box = JTextArea('') self.ui_log_box.setLineWrap(True) self.ui_log_box.setEditable(False) self.ui_log_scroll_pane = JScrollPane(self.ui_log_box) self.ui_log_scroll_pane.setBounds(20, 190, self.log_box_width, self.log_box_height) self.panel.add(self.ui_client_dnslog_label_1) self.panel.add(self.ui_client_ip_label_1) self.panel.add(self.ui_client_ip) self.panel.add(self.ui_client_url_label_1) self.panel.add(self.ui_client_url) self.panel.add(self.ui_button_label) #self.panel.add(self.ui_web_test_button) self.panel.add(self.ui_save_button) self.panel.add(self.ui_log_scroll_pane) self.tools.panel = self.panel self.tools.log_box = self.ui_log_box self.tools.log_scroll_pane = self.ui_log_scroll_pane
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")
def buildpane(self): buttons = JPanel(FlowLayout(), doublebuffered) buttons.add(JButton("Send Message", actionPerformed=self.message)) buttons.add(JButton("Add Contact", actionPerformed=self.addContact)) #buttons.add(JButton("Quit", actionPerformed=self.quit)) mainpane = self.mainframe.getContentPane() mainpane.setLayout(BoxLayout(mainpane, BoxLayout.Y_AXIS)) mainpane.add(JScrollPane(self.table)) mainpane.add(buttons) self.update()
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 buildpane(self): buttons = JPanel(doublebuffered) buttons.add(JButton("Send", actionPerformed=self.send)) buttons.add(JButton("Hide", actionPerformed=self.hidewindow)) mainpane = self.mainframe.getContentPane() mainpane.setLayout(BoxLayout(mainpane, BoxLayout.Y_AXIS)) mainpane.add(JScrollPane(self.display)) self.typepad.actionPerformed = self.send mainpane.add(self.typepad) mainpane.add(buttons)
def getUiComponent(self): panel = JPanel(BorderLayout()) panel.setLocation(100, 100) panel.setLayout(None) lbl1 = JLabel("Insert URL") lbl1.setBounds(60, 20, 100, 40) txt1 = JTextField(100) txt1.setBounds(140, 20, 600, 40) def btn1Click(event): import requests from bs4 import BeautifulSoup url = requests.get("http://" + str(txt1.text)) # a=requests.get(str(txt1.text)) req = url.text links = [] soup = BeautifulSoup(url.text, 'html.parser') for link in soup.find_all('a'): links.append(link.get('href')) links = ((str(links).replace("[", "")).replace("]", "")).replace("u'", "'") txt2.text = links #set info por table2 txt2.editable = False txt2.wrapStyleWord = True txt2.lineWrap = True text2.aligmentx = Component.LEFT_ALIGMENT txt2.size(300, 1) return btn = JButton("Click", actionPerformed=btn1Click) btn.setBounds(400, 80, 60, 30) panel.add(lbl1, BorderLayout.CENTER) panel.add(txt1, BorderLayout.CENTER) panel.add(btn, BorderLayout.CENTER) lbl2 = JLabel("Output URLs") lbl2.setBounds(60, 80, 150, 40) txt2 = JTextArea() txt2.setBounds(140, 120, 600, 600) txt2.setBackground(Color.WHITE) # set table color, if you want panel.add(lbl2, BorderLayout.CENTER) panel.add(txt2, BorderLayout.CENTER) return panel
def initEnforcementDetector(self): # ## init enforcement detector tab # # These two variable appears to be unused... self.EDFP = ArrayList() self.EDCT = ArrayList() EDLType = JLabel("Type:") EDLType.setBounds(10, 10, 140, 30) EDLContent = JLabel("Content:") EDLContent.setBounds(10, 50, 140, 30) EDLabelList = JLabel("Filter List:") EDLabelList.setBounds(10, 165, 140, 30) EDStrings = [ "Headers (simple string): (enforced message headers contains)", "Headers (regex): (enforced messege headers contains)", "Body (simple string): (enforced messege body contains)", "Body (regex): (enforced messege body contains)", "Full request (simple string): (enforced messege contains)", "Full request (regex): (enforced messege contains)", "Content-Length: (constant Content-Length number of enforced response)" ] self.EDType = JComboBox(EDStrings) self.EDType.setBounds(80, 10, 430, 30) self.EDText = JTextArea("", 5, 30) self.EDText.setBounds(80, 50, 300, 110) self.EDModel = DefaultListModel() self.EDList = JList(self.EDModel) self.EDList.setBounds(80, 175, 300, 110) self.EDList.setBorder(LineBorder(Color.BLACK)) self.EDAdd = JButton("Add filter", actionPerformed=self.addEDFilter) self.EDAdd.setBounds(390, 85, 120, 30) self.EDDel = JButton("Remove filter", actionPerformed=self.delEDFilter) self.EDDel.setBounds(390, 210, 120, 30) self.EDPnl = JPanel() self.EDPnl.setLayout(None) self.EDPnl.setBounds(0, 0, 1000, 1000) self.EDPnl.add(EDLType) self.EDPnl.add(self.EDType) self.EDPnl.add(EDLContent) self.EDPnl.add(self.EDText) self.EDPnl.add(self.EDAdd) self.EDPnl.add(self.EDDel) self.EDPnl.add(EDLabelList) self.EDPnl.add(self.EDList)
def __init__(self, view, handler): JButton.__init__(self) self.view = view self.icon = GUIUtilities.loadIcon("Find.png") self.margin = Insets(0, 0, 0, 0) self.handler = handler self.alignY = 1 self.actionPerformed = self.action self.cursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR) self.toolTipText = u"Jump to error file %s:%s" % (unicode( handler[0]), unicode(handler[1]))
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)
def initGui(self): def make_game_selector(): self.gameChanger = False def dbChange(evt): if evt.source.text: self.gamedb = GameDB(evt.source.text) self.gameChanger = True def idChange(evt): if evt.source.text: self.gameid = evt.source.text self.gameChanger = True def turnChange(evt): if evt.source.text: self.turnid = evt.source.text self.gameChanger = True selector = JPanel() selector.add(JLabel("DB:")) selector.add(textfield(self.gamedb.dbfile, dbChange)) selector.add(JLabel("Game ID:")) selector.add(textfield(self.gameid, idChange)) selector.add(JLabel("Turn ID:")) selector.add(textfield(self.turnid, turnChange)) return JScrollPane(selector) def make_content_panel(): self.contentPanel = JPanel(GridLayout(1, 0, 5, 5)) self.render() return JScrollPane(self.contentPanel) def save(self, txt, filename): pass def make_code_editor(): import inspect panel = JPanel(BorderLayout(2,2)) self.codeArea = JTextArea() self.codeArea.text = self.scoringModule and inspect.getsource(self.scoringModule) or "" panel.add(JScrollPane(self.codeArea), BorderLayout.CENTER) return panel self.frame.contentPane.add(make_game_selector(), BorderLayout.NORTH) # self.frame.contentPane.add(make_content_panel(), BorderLayout.WEST) # self.frame.contentPane.add(make_code_editor(), BorderLayout.CENTER) pane = JSplitPane(JSplitPane.HORIZONTAL_SPLIT, make_content_panel(), make_code_editor()) pane.setDividerLocation(self.frame.width/2) self.frame.contentPane.add(pane) reloadButton = JButton("Reload") def reload(evt): self.reload() reloadButton.addActionListener(reload) self.frame.contentPane.add(reloadButton, BorderLayout.SOUTH)
def buildpane(self): buttons = JPanel(FlowLayout(), doublebuffered) buttons.add(self.connectbutton) buttons.add(self.dconnbutton) buttons.add(JButton("New", actionPerformed=self.addNewAccount)) buttons.add(self.deletebutton) buttons.add(JButton("Quit", actionPerformed=self.quit)) mainpane = self.mainframe.getContentPane() mainpane.layout = BoxLayout(mainpane, BoxLayout.Y_AXIS) mainpane.add(JScrollPane(self.table)) mainpane.add(buttons) self.update()
def __init__(self): self.dir_path = '' self.panel = JPanel() box_layout = BoxLayout(self.panel, BoxLayout.Y_AXIS) self.panel.setLayout(box_layout) self.panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)) self.choose_dir_label = JLabel('Experiment Folder:') self.choose_dir_textField = JTextField(30) self.choose_dir_textField.addActionListener( ActionListenerFactory(self, self.textField_al)) self.choose_dir_button = JButton('open') self.choose_dir_button.addActionListener( ActionListenerFactory(self, self.choose_dir_al)) self.choose_dir_panel = JPanel() self.choose_dir_panel.add(self.choose_dir_label) self.choose_dir_panel.add(self.choose_dir_textField) self.choose_dir_panel.add(self.choose_dir_button) self.panel.add(self.choose_dir_panel) # root = DefaultMutableTreeNode() # self.meta_data_mode_label = JLabel('Autogenerated meta_data file mode') # self.raw_stack_mode = JRadioButton('raw stack mode') # self.projection_mode = JRadioButton('projection files mode') # # self.meta_data_mode = ButtonGroup() # self.meta_data_mode.add(self.raw_stack_mode) # self.meta_data_mode.add(self.projection_mode) # # self.meta_data_mode_panel = JPanel(GridLayout(0, 1)) # self.meta_data_mode_panel.add(self.meta_data_mode_label) # self.meta_data_mode_panel.add(self.raw_stack_mode) # self.meta_data_mode_panel.add(self.projection_mode) # # self.panel.add(self.meta_data_mode_panel) self.run_button = JButton('Run') self.run_button.addActionListener( ActionListenerFactory(self, self.run_button_al)) self.panel.add(self.run_button) super(BobGui, self).__init__("BobPy") self.getContentPane().add(self.panel) self.pack() self.setLocationRelativeTo(None) self.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) self.setVisible(True)
def registerExtenderCallbacks(self, callbacks): # properties self._title = "Generate Python Template" self._templatePath = '###### ----> PUT HERE THE ABSOLUTE PATH TO template.py <--- ####' # set our extension name callbacks.setExtensionName(self._title) # keep a reference to our callbacks object self._callbacks = callbacks # obtain an extension helpers object self._helpers = callbacks.getHelpers() # obtain std streams self._stdout = PrintWriter(callbacks.getStdout(), True) self._stderr = PrintWriter(callbacks.getStderr(), True) # main pane (top/bottom) self._mainpane = JPanel() self._mainpane.setLayout(GridLayout(2, 1)) # configure bottom pane for buttons self._botPane = JPanel() flowLayout = FlowLayout() self._botPane.setLayout(flowLayout) self._botPane.add( JButton("Generate", actionPerformed=self.regeneratePy)) self._botPane.add(JButton("Export", actionPerformed=self.exportPy)) # Configure pyViewer (JTextArea) for python output --> top pane self._pyViewer = JTextArea(5, 20) scrollPane = JScrollPane(self._pyViewer) self._pyViewer.setEditable(True) self._pyViewer.setText("Waiting request ...") ### Assign top / bottom components self._mainpane.add(scrollPane) self._mainpane.add(self._botPane) # customize our UI components callbacks.customizeUiComponent(self._mainpane) # add the custom tab to Burp's UI callbacks.addSuiteTab(self) # register ourselves as a ContextMenuFactory callbacks.registerContextMenuFactory(self) return
def __init__(self, extender, controller, editable): self._extender = extender self._panel = JPanel() # main panel # type combobox for tables self._types = Parameter.type_mapping.values() + ["- Remove Row -"] self._actions = ["replace", "insert", "delete"] # define the GridBagLayout ( 4x4 ) gridBagLayout = GridBagLayout() gridBagLayout.columnWidths = [0, 0, 0, 0] gridBagLayout.rowHeights = [0, 0, 0, 0] gridBagLayout.columnWeights = [1.0, 0.0, 0.0, 0.0] gridBagLayout.rowWeights = [0.0, 1.0, 5.0, 0.0] self._panel.setLayout(gridBagLayout) # JComboBox for Session selection self._session_selector = JComboBox(extender.sm.sessions, itemStateChanged=self.changeSession) self._session_selector_model = self._session_selector.getModel() gbc_session_selector = _new_grid_bag(0, 0) self._panel.add(self._session_selector, gbc_session_selector) # "Delete Session" Button del_session = JButton("Delete Session", actionPerformed=self.deleteSession) gbc_del_session = _new_grid_bag(1, 0) self._panel.add(del_session, gbc_del_session) # "New Session" Button new_session = JButton("New Session", actionPerformed=self.new_session) gbc_new_session = _new_grid_bag(2, 0) self._panel.add(new_session, gbc_new_session) # Table containing modified parameters self.modification_table = JTable() self.update_table() gbc_modification_table = _new_grid_bag(0, 1, 3) self._panel.add(JScrollPane(self.modification_table), gbc_modification_table) self.modification_table.setPreferredScrollableViewportSize( self.modification_table.getPreferredSize()) self.modification_table.setFillsViewportHeight(True) # HTTP message editor self._editor = self._extender.callbacks.createTextEditor() gbc_messageEditor = _new_grid_bag(0, 2, 3) self._panel.add(self._editor.getComponent(), gbc_messageEditor)
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
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 install(helper): print('install called'); frame = JFrame("Please Input Values") frame.setLocation(100,100) frame.setSize(500,400) frame.setLayout(None) lbl1 = JLabel("Input1: ") lbl1.setBounds(60,20,60,20) txt1 = JTextField(100) txt1.setBounds(130,20,200,20) lbl2 = JLabel("Input2: ") lbl2.setBounds(60,50,100,20) txt2 = JTextField(100) txt2.setBounds(130,50,200,20) lbl3 = JLabel("Input3: ") lbl3.setBounds(60,80,140,20) txt3 = JTextField(100) txt3.setBounds(130,80,200,20) lbl4 = JLabel("Input4: ") lbl4.setBounds(60,110,180,20) txt4 = JTextField(100) txt4.setBounds(130,110,200,20) def getValues(event): print "clicked" ScriptVars.setGlobalVar("Input1",str(txt1.getText())) print(ScriptVars.getGlobalVar("Input1")) ScriptVars.setGlobalVar("Input2",str(txt2.getText())) print(ScriptVars.getGlobalVar("Input2")) ScriptVars.setGlobalVar("Input3",str(txt3.getText())) print(ScriptVars.getGlobalVar("Input3")) ScriptVars.setGlobalVar("Input4",str(txt4.getText())) print(ScriptVars.getGlobalVar("Input4")) btn = JButton("Submit", actionPerformed = getValues) btn.setBounds(160,150,100,20) frame.add(lbl1) frame.add(txt1) frame.add(lbl2) frame.add(txt2) frame.add(btn) frame.add(lbl3) frame.add(txt3) frame.add(lbl4) frame.add(txt4) frame.setVisible(True)
def install(helper): print('install called') frame = JFrame("Please Input Values") frame.setLocation(100, 100) frame.setSize(500, 400) frame.setLayout(None) lbl1 = JLabel("Input1: ") lbl1.setBounds(60, 20, 60, 20) txt1 = JTextField(100) txt1.setBounds(130, 20, 200, 20) lbl2 = JLabel("Input2: ") lbl2.setBounds(60, 50, 100, 20) txt2 = JTextField(100) txt2.setBounds(130, 50, 200, 20) lbl3 = JLabel("Input3: ") lbl3.setBounds(60, 80, 140, 20) txt3 = JTextField(100) txt3.setBounds(130, 80, 200, 20) lbl4 = JLabel("Input4: ") lbl4.setBounds(60, 110, 180, 20) txt4 = JTextField(100) txt4.setBounds(130, 110, 200, 20) def getValues(event): print "clicked" ScriptVars.setGlobalVar("Input1", str(txt1.getText())) print(ScriptVars.getGlobalVar("Input1")) ScriptVars.setGlobalVar("Input2", str(txt2.getText())) print(ScriptVars.getGlobalVar("Input2")) ScriptVars.setGlobalVar("Input3", str(txt3.getText())) print(ScriptVars.getGlobalVar("Input3")) ScriptVars.setGlobalVar("Input4", str(txt4.getText())) print(ScriptVars.getGlobalVar("Input4")) btn = JButton("Submit", actionPerformed=getValues) btn.setBounds(160, 150, 100, 20) frame.add(lbl1) frame.add(txt1) frame.add(lbl2) frame.add(txt2) frame.add(btn) frame.add(lbl3) frame.add(txt3) frame.add(lbl4) frame.add(txt4) frame.setVisible(True)
def changePasswordForm(check): global frame global tfOldPassword global tfNewPassword global tfConfirmPassword global value value = check frame = JFrame("Change Password") frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) frame.setSize(500, 350) frame.setLocation(200, 200) frame.setLayout(None) frame.setVisible(True) panel = JPanel() panel.setSize(500, 350) panel.setLocation(0, 0) panel.setLayout(None) panel.setVisible(True) panel.setBackground(Color.LIGHT_GRAY) heading = JLabel("Change Password") heading.setBounds(200, 30, 150, 40) lbOldPassword = JLabel("Old Password") lbNewPassword = JLabel("New Password") lbConfirmPassword = JLabel("Confirm Password") tfOldPassword = JTextField() tfNewPassword = JTextField() tfConfirmPassword = JTextField() lbOldPassword.setBounds(50, 100, 150, 30) lbNewPassword.setBounds(50, 150, 150, 30) lbConfirmPassword.setBounds(50, 200, 150, 30) tfOldPassword.setBounds(220, 100, 150, 30) tfNewPassword.setBounds(220, 150, 150, 30) tfConfirmPassword.setBounds(220, 200, 150, 30) btnSave = JButton("Save", actionPerformed=clickSave) btnCancel = JButton("Cancel", actionPerformed=clickCancel) btnSave.setBounds(350, 280, 100, 30) btnCancel.setBounds(50, 280, 100, 30) panel.add(heading) panel.add(lbOldPassword) panel.add(lbNewPassword) panel.add(lbConfirmPassword) panel.add(tfOldPassword) panel.add(tfNewPassword) panel.add(tfConfirmPassword) panel.add(btnSave) panel.add(btnCancel) frame.add(panel)
def __init__(self): self.mainDir = "" self.frame = JFrame("Dots Quality Check", size=(250,300)) self.frame.setLocation(20,120) self.Panel = JPanel(GridLayout(0,1)) self.frame.add(self.Panel) self.openNextButton = JButton('Open Next Random',actionPerformed=openRandom) self.Panel.add(self.openNextButton) self.saveButton = JButton('Save',actionPerformed=save) self.saveButton.setEnabled(False) self.Panel.add(self.saveButton) self.cropButton = JButton('Crop values from here', actionPerformed=cropVals) self.Panel.add(self.cropButton) self.DiscardButton = JButton('Discard cell', actionPerformed=discardCell) self.DiscardButton.setEnabled(True) self.Panel.add(self.DiscardButton) self.quitButton = JButton('Quit script',actionPerformed=quit) self.Panel.add(self.quitButton) annoPanel = JPanel() #add gridlayout wtRButton = JRadioButton("wt", actionCommand="wt") defectRButton = JRadioButton("Defect", actionCommand="defect") annoPanel.add(wtRButton) annoPanel.add(defectRButton) self.aButtonGroup = ButtonGroup() self.aButtonGroup.add(wtRButton) self.aButtonGroup.add(defectRButton) self.Panel.add(annoPanel) self.ProgBar = JProgressBar() self.ProgBar.setStringPainted(True) self.ProgBar.setValue(0) self.Panel.add(self.ProgBar) self.pathLabel = JLabel("-- No main directory chosen --") self.pathLabel.setHorizontalAlignment( SwingConstants.CENTER ) self.Panel.add(self.pathLabel) WindowManager.addWindow(self.frame) self.show()
def __init__(self, controller): # Give reference to controller to delegate action response self.controller = controller # TODO Refactor to avoid duplication - See issue#16 # https://github.com/UCL-RITS/nammu/issues/16 # Content needs to be displayed in an orderly fashion so that buttons # are placed where we expect them to be, not in the ramdon order dicts # have. # We also can't create the tooltips dict e.g.: # tooltips = { 'a' : 'A', 'b' : 'B', 'c' : 'C' } # because it will still be randomly ordered. Elements need to be added # to the dict in the order we want them to be placed in the toolbar for # OrderedDict to work tooltips = {} tooltips = collections.OrderedDict() tooltips['newFile'] = 'Creates empty ATF file for edition' tooltips['openFile'] = 'Opens ATF file for edition' tooltips['saveFile'] = 'Saves current file' tooltips['saveAsFile'] = 'Save As...' tooltips['closeFile'] = 'Closes current file' tooltips['printFile'] = 'Prints current file' tooltips['undo'] = 'Undo last action' tooltips['redo'] = 'Redo last undone action' tooltips['copy'] = 'Copy text selection' tooltips['cut'] = 'Cut text selection' tooltips['paste'] = 'Paste clipboard content' tooltips['syntax_highlight_switch'] = 'Switch on/off syntax_highlight' tooltips['validate'] = 'Check current ATF correctness' tooltips['lemmatise'] = 'Obtain lemmas for current ATF text' tooltips['displayModelView'] = 'Change to ATF data model view' tooltips['editSettings'] = 'Change Nammu settings' tooltips['showHelp'] = 'Displays ATF documentation' tooltips['showAbout'] = 'Displays information about Nammu and ORACC' tooltips['quit'] = 'Exits Nammu' for name, tooltip in tooltips.items(): icon = ImageIcon(find_image_resource(name)) button = JButton(icon, actionPerformed=getattr(self, name)) button.setToolTipText(tooltip) self.add(button) # Work out is separator is needed if name in [ 'printFile', 'redo', 'paste', 'syntax_highlight_switch', 'lemmatise', 'unicode', 'console', 'displayModelView', 'showAbout' ]: self.addSeparator()
def initUI(self): panel = JPanel() self.getContentPane().add(panel) panel.setLayout(None) qbutton = JButton("Quit", actionPerformed=self.onQuit) qbutton.setBounds(50, 60, 80, 30) panel.add(qbutton) self.setTitle("Quit Button") self.setSize(300, 200) self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) self.setLocationRelativeTo(None) self.setVisible(True)
def create_file_choice_button(name, label_text): button = JButton('Click to select') label = JLabel(label_text) file_chooser = JFileChooser() def choose_file(event): user_did_choose_file = (file_chooser.showOpenDialog(frame) == JFileChooser.APPROVE_OPTION) if user_did_choose_file: file_ = file_chooser.getSelectedFile(); button.text = chosen_values[name] = str(file_) button.actionPerformed = choose_file panel.add(label) panel.add(button)
def __init__(self): self.acctmanager = AccountManager() self.mainframe = JFrame("Account Manager") self.chatui = None self.headers = ["Account Name", "Status", "Autologin", "Gateway"] self.data = UneditableTableModel([], self.headers) self.table = JTable(self.data) self.table.columnSelectionAllowed = 0 # cannot select columns self.table.selectionMode = ListSelectionModel.SINGLE_SELECTION self.connectbutton = JButton("Connect", actionPerformed=self.connect) self.dconnbutton = JButton("Disconnect", actionPerformed=self.disconnect) self.deletebutton = JButton("Delete", actionPerformed=self.deleteAccount) self.buildpane() self.mainframe.pack() self.mainframe.show()
def initExport(self): # ## init enforcement detector tab # exportLType = JLabel("File Type:") exportLType.setBounds(10, 10, 100, 30) exportLES = JLabel("Enforcement Statuses:") exportLES.setBounds(10, 50, 160, 30) exportFileTypes = ["HTML","CSV"] self.exportType = JComboBox(exportFileTypes) self.exportType.setBounds(100, 10, 200, 30) exportES = ["All Statuses", self._enfocementStatuses[0], self._enfocementStatuses[1], self._enfocementStatuses[2]] self.exportES = JComboBox(exportES) self.exportES.setBounds(100, 50, 200, 30) exportLES = JLabel("Statuses:") exportLES.setBounds(10, 50, 100, 30) self.exportButton = JButton("Export",actionPerformed=self.export) self.exportButton.setBounds(390, 25, 100, 30) self.exportPnl = JPanel() self.exportPnl.setLayout(None); self.exportPnl.setBounds(0, 0, 1000, 1000); self.exportPnl.add(exportLType) self.exportPnl.add(self.exportType) self.exportPnl.add(exportLES) self.exportPnl.add(self.exportES) self.exportPnl.add(self.exportButton)
def makeScriptButton(button_name,script_name): from javax.swing import JButton from java.awt.event import ActionListener btn = JButton(button_name) #defin a class to invoke a script # creating a class called action which does not exist # this creates a python class deriving from ActionListener( a java class) class action(ActionListener): # defines a constructor def __init__(self,sname): self.sname = sname def actionPerformed(self, event): execfile(self.sname) # registers an instance of the action object with the button btn.addActionListener(action(script_name)) return btn
def init(self): self.getContext().addPropertyChangeListener(self) #ThrottleFrame change self.getContext().getCurrentThrottleFrame().getAddressPanel().addAddressListener(self) # change of throttle in Current frame self.addressPanel = self.getContext().getCurrentThrottleFrame().getAddressPanel() self.throttle = self.addressPanel.getThrottle() # the throttle self.roster = self.addressPanel.getRosterEntry() # roster entry if any self.speedAction = SpeedAction() #Speed increase thread self.speedAction.setThrottle( self.throttle ) self.speedTimer = Timer(valueSpeedTimerRepeat, self.speedAction ) # Very important to use swing Timer object (see Swing and multithreading doc) self.speedTimer.setRepeats(True) self.label = JButton(ImageIcon(self.getFolder() + "/USBControl.png","USBThrottle")) #label self.label.addMouseListener(self.getMouseListeners()[0]) # In order to get the popupmenu on the button too self.add(self.label) self.model = jmri.jmrix.jinput.TreeModel.instance() # USB self.desiredController = None self.ctrlMenuItem = [] self.USBDriver = None self.driver = None mi = JCheckBoxMenuItem ("None") self.getPopUpMenu().add( mi ) mi.addItemListener( ControllerItemListener(None, self) ) self.ctrlMenuItem.append(mi) for ctrl in self.model.controllers(): mi = JCheckBoxMenuItem (ctrl.getName()) self.getPopUpMenu().add( mi ) mi.addItemListener( ControllerItemListener(ctrl, self) ) self.ctrlMenuItem.append(mi) if ( len(self.ctrlMenuItem) == 0 ): print "No matching USB device found" else: self.ctrlMenuItem[0].setSelected(True) # by default connect to the first one self.model.addPropertyChangeListener(self) self.lastTimeStopButton = Calendar.getInstance().getTimeInMillis() self.lastTimeCruiseButton = Calendar.getInstance().getTimeInMillis()
def __init__(self, controller): #Give reference to controller to delegate action response self.controller = controller #TODO Refactor to avoid duplication - See issue#16 #https://github.com/UCL-RITS/nammu/issues/16 #Content needs to be displayed in an orderly fashion so that buttons are #placed where we expect them to be, not in the ramdon order dicts have. #We also can't create the tooltips dict e.g.: #tooltips = { 'a' : 'A', 'b' : 'B', 'c' : 'C' } #because it will still be randomly ordered. Elements need to be added to #the dict in the order we want them to be placed in the toolbar for #OrderedDict to work tooltips = {} tooltips = collections.OrderedDict() tooltips['newFile'] = 'Creates empty ATF file for edition' tooltips['openFile'] = 'Opens ATF file for edition' tooltips['saveFile'] = 'Saves current file' tooltips['closeFile'] = 'Closes current file' tooltips['printFile'] = 'Prints current file' tooltips['undo'] = 'Undo last action' tooltips['redo'] = 'Redo last undone action' tooltips['copy'] = 'Copy text selection' tooltips['cut'] = 'Cut text selection' tooltips['validate'] = 'Check current ATF correctness' tooltips['paste'] = 'Paste clipboard content' tooltips['lemmatise'] = 'Obtain lemmas for current ATF text' tooltips['unicode'] = 'Use Unicode characters' tooltips['console'] = 'View/Hide Console' tooltips['displayModelView'] = 'Change to ATF data model view' tooltips['editSettings'] = 'Change Nammu settings' tooltips['showHelp'] = 'Displays ATF documentation' tooltips['showAbout'] = 'Displays information about Nammu and ORACC' tooltips['quit'] = 'Exits Nammu' for name, tooltip in tooltips.items(): icon = ImageIcon(self.findImageResource(name)) button = JButton(icon, actionPerformed = getattr(self, name)) button.setToolTipText(tooltips[name]) self.add(button) #Work out is separator is needed if name in ['printFile', 'redo', 'paste', 'lemmatise', 'unicode', 'console', 'displayModelView', 'showAbout']: self.addSeparator()
def initEnforcementDetector(self): # ## init enforcement detector tab # # These two variable appears to be unused... self.EDFP = ArrayList() self.EDCT = ArrayList() EDLType = JLabel("Type:") EDLType.setBounds(10, 10, 140, 30) EDLContent = JLabel("Content:") EDLContent.setBounds(10, 50, 140, 30) EDLabelList = JLabel("Filter List:") EDLabelList.setBounds(10, 165, 140, 30) EDStrings = ["Headers (simple string): (enforced message headers contains)", "Headers (regex): (enforced messege headers contains)", "Body (simple string): (enforced messege body contains)", "Body (regex): (enforced messege body contains)", "Full request (simple string): (enforced messege contains)", "Full request (regex): (enforced messege contains)", "Content-Length: (constant Content-Length number of enforced response)"] self.EDType = JComboBox(EDStrings) self.EDType.setBounds(80, 10, 430, 30) self.EDText = JTextArea("", 5, 30) self.EDText.setBounds(80, 50, 300, 110) self.EDModel = DefaultListModel(); self.EDList = JList(self.EDModel); self.EDList.setBounds(80, 175, 300, 110) self.EDList.setBorder(LineBorder(Color.BLACK)) self.EDAdd = JButton("Add filter",actionPerformed=self.addEDFilter) self.EDAdd.setBounds(390, 85, 120, 30) self.EDDel = JButton("Remove filter",actionPerformed=self.delEDFilter) self.EDDel.setBounds(390, 210, 120, 30) self.EDPnl = JPanel() self.EDPnl.setLayout(None); self.EDPnl.setBounds(0, 0, 1000, 1000); self.EDPnl.add(EDLType) self.EDPnl.add(self.EDType) self.EDPnl.add(EDLContent) self.EDPnl.add(self.EDText) self.EDPnl.add(self.EDAdd) self.EDPnl.add(self.EDDel) self.EDPnl.add(EDLabelList) self.EDPnl.add(self.EDList)
def createSNTPanel(): # Create out control panel panel = JPanel() button = JButton("Run SNT") panel.add(button) panel.add(JButton("Remove panel", actionPerformed=removeSNTPanel)) op = OptionPanel() layers = [] cal = front.getLayerSet().getCalibrationCopy() for i, layer in enumerate(front.getLayerSet().getLayers()): layers.append(str(i+1) + ": " + str(IJ.d2s(layer.getZ() * cal.pixelWidth, 2))) c1 = op.addChoice("First section:", layers, 0, None) c2 = op.addChoice("Last section:", layers, len(layers)-1) button.addActionListener(Listener(c1, c2)) panel.add(op) return panel
def getContentPane(): global contentPane global devicesList global devicesPanel if not contentPane: global devicesListLabel devicesListLabel = JLabel("Devices") global devicesList devicesList = JList([]) devicesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) listScroller = JScrollPane(devicesList) listScroller.setPreferredSize(Dimension(600, 400)) global connectButton global focusButton allDevsButton = JButton(ALL_DEVICES, actionPerformed=handleAllDevsBtn) connectedDevsButton = JButton(CONNECTED_DEVICES, actionPerformed=handleConnectedDevBtn) connectButton = JButton(CONNECT, actionPerformed=handleConnectBtn) focusButton = JButton(FOCUS, actionPerformed=handleFocusBtn) focusButton.setVisible(False) goInButton = JButton("Go in device", actionPerformed=handleGoInBtn) deviceListButtons = JPanel() deviceListButtons.add(allDevsButton) deviceListButtons.add(connectedDevsButton) deviceListButtons.add(connectButton) deviceListButtons.add(focusButton) deviceListButtons.add(goInButton) devicesPanel = JPanel() devicesPanel.setLayout(BoxLayout(devicesPanel, BoxLayout.Y_AXIS)) devicesPanel.add(devicesListLabel) devicesPanel.add(listScroller) devicesPanel.add(deviceListButtons) contentPane = JPanel() contentPane.setLayout(BorderLayout()) contentPane.add(devicesPanel, BorderLayout.WEST) contentPane.add(getControlPanel(), BorderLayout.EAST) contentPane.add(getScreenPanel(), BorderLayout.CENTER) getScreenPanel().setVisible(False) return contentPane
def makeScriptComboBox(list): from javax.swing import JComboBox, JButton, JPanel from java.awt.event import ActionListener jcb = JComboBox(list) jcb.setSelectedIndex(0) plot_btn = JButton("Plot station") # create a Python class class PlotButtonAction(ActionListener): # defines a constructor def __init__(self, combo_box): self.cb = combo_box def actionPerformed(self, event): plotStation(self.cb.getSelectedIndex(), None) # registers an instance of the action object with the button plot_btn.addActionListener(PlotButtonAction(jcb)) # alltw_btn = JButton("All Data") class AllButtonAction(ActionListener): # defines a constructor def __init__(self, combo_box): self.cb = combo_box def actionPerformed(self, event): plotStation(self.cb.getSelectedIndex(), 1) alltw_btn.addActionListener(AllButtonAction(jcb)) # quit_btn = JButton("Quit") class QuitButtonAction(ActionListener): # defines a constructor def __init__(self, combo_box): self.cb = combo_box def actionPerformed(self, event): fr.dispose() quit_btn.addActionListener(QuitButtonAction(jcb)) # add both button and combo box to a panel panel = JPanel() panel.setLayout(GridLayout(2, 2)) panel.add(alltw_btn) panel.add(jcb) panel.add(plot_btn) panel.add(quit_btn) return panel
def initUI(self): panel = JPanel() self.getContentPane().add(panel) panel.setLayout(None) panel.setToolTipText("A panel container") button = JButton("Button") button.setBounds(100, 60, 100, 30) button.setToolTipText("A button component") panel.add(button) self.setTitle("Tooltips") self.setSize(300, 200) self.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) self.setLocationRelativeTo(None) self.setVisible(True)