def __init__(self): #color = Color(.25,.25,.25,1) self.ng = ca.nengo.ui.NengoGraphics.getInstance() self.toolbar = JToolBar("Nengo actions", floatable=False) #self.toolbar.setBackground(color) ### Make and add buttons self.toolbar.add(make_button('open', self.do_open, 'open file')) self.toolbar.add(make_button( 'savefile', self.do_save, 'save selected network')) self.button_scriptgen = make_button( 'scriptgen', self.do_scriptgen, 'generate selected network script', enabled=False) self.toolbar.add(self.button_scriptgen) self.toolbar.add(make_button('clear', self.do_clear_all, 'clear all')) self.toolbar.add(Box.createHorizontalGlue()) self.toolbar.add(make_button('inspect', self.do_inspect, 'inspect')) self.button_run = make_button( 'interactive', self.do_run, 'interactive plots', enabled=False) self.toolbar.add(self.button_run) SelectionHandler.addSelectionListener(self) self.ng.getWorld().getGround().addChildrenListener(self) self.ng.setToolbar(self.toolbar)
def leftJustify( panel ): b = Box.createHorizontalBox() b.add( panel ) b.add( Box.createHorizontalGlue() ) # (Note that you could throw a lot more components # and struts and glue in here.) return b
def __init__(self, program): self.setLayout(BorderLayout()) title = JLabel(program.title) title.setFont(Font("Arial", Font.BOLD, 28)) title.setHorizontalAlignment(JLabel.CENTER) title.setVerticalAlignment(JLabel.CENTER) title.setBorder(createEmptyBorder(15, 5, 15, 5)) if not program.public: lbl = JLabel("Private") lbl.setFont(Font("Arial", Font.BOLD, 20)) lbl.setForeground(Color(0xFF2424)) lbl.setBorder(createEmptyBorder(15, 15, 15, 15)) leftbox = lbl else: leftbox = Box.createHorizontalGlue() btnbox = TitleBtnBox(program) btnbox.setBorder(createEmptyBorder(5, 5, 5, 5)) self.add(leftbox, BorderLayout.LINE_START) self.add(title, BorderLayout.CENTER) self.add(btnbox, BorderLayout.LINE_END) same_size(leftbox, btnbox) self.setMaximumSize(Dimension(99999, self.getPreferredSize().height))
def __init__(self): self.setBorder(BorderFactory.createTitledBorder( "Setup a session handling action to" + " remove named cookies from Burp's" + " cookie jar")) self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS)) self._rowpanel1 = PTListPanel("Cookies to remove", []) self._rowpanel2 = JPanel() self._rowpanel2.setLayout(BoxLayout(self._rowpanel2, BoxLayout.X_AXIS)) self._button_update = JButton( "Add a new \"Remove cookies\" session handler" " for these cookies", actionPerformed=self._button_update_pressed ) self._rowpanel2.add(Box.createHorizontalGlue()) self._rowpanel2.add(self._button_update) self.add(self._rowpanel1) self.add(self._rowpanel2)
def add_UI_entry(self,key, dico=dict()): UI_key_dict = dict() UI_key_dict['JP'] = JPanel() UI_key_dict['JP'].setLayout(BoxLayout(UI_key_dict['JP'], BoxLayout.X_AXIS)) UI_key_dict['JRB'] = JRadioButton() self.select_key_rb_group.add(UI_key_dict['JRB']) self.hash4keys[UI_key_dict['JRB']] = key UI_key_dict['JB'] = JButton(key, actionPerformed=self.set_key) UI_key_dict['JB'].setPreferredSize(Dimension(100,25)) UI_key_dict['JPP'] = JPanel() UI_key_dict['JP'].add(UI_key_dict['JRB']) UI_key_dict['JP'].add(UI_key_dict['JB']) UI_key_dict['JP'].add(Box.createRigidArea(Dimension(15, 0))) UI_key_dict['JP'].add(UI_key_dict['JPP']) UI_key_dict['JPP'].setLayout(BoxLayout(UI_key_dict['JPP'], BoxLayout.Y_AXIS)) self.panelEntries.add(UI_key_dict['JP']) for param in self.param_list: if param not in dico.keys(): continue if param == 'DEFAULT': UI_key_dict[param] = {'JP':JPanel(), 'JRB': JRadioButton('is Default')} UI_key_dict[param]['JP'].setLayout(BoxLayout( UI_key_dict[param]['JP'], BoxLayout.X_AXIS)) UI_key_dict[param]['JP'].add(UI_key_dict[param]['JRB']) UI_key_dict[param]['JP'].add(Box.createHorizontalGlue()) self.select_default_rb_group.add(UI_key_dict[param]['JRB']) UI_key_dict['JPP'].add(UI_key_dict[param]['JP']) UI_key_dict[param]['JRB'].setSelected(dico[param]) self.hash4keys[UI_key_dict[param]['JRB']] = key continue UI_key_dict[param] = { 'JP':JPanel(), 'JL': JLabel(param+": "), 'JB': JButton(dico[param]) } self.hash4keys[UI_key_dict[param]['JB']] = key UI_key_dict[param]['JL'].setPreferredSize(Dimension(100,25)) UI_key_dict[param]['JB'].actionPerformed = self.actions_list[param] UI_key_dict[param]['JP'].setLayout(BoxLayout(UI_key_dict[param]['JP'], BoxLayout.X_AXIS)) UI_key_dict[param]['JP'].add(UI_key_dict[param]['JL']) UI_key_dict[param]['JP'].add(UI_key_dict[param]['JB']) UI_key_dict[param]['JP'].add(Box.createHorizontalGlue()) UI_key_dict['JPP'].add(UI_key_dict[param]['JP']) UI_key_dict['JPP'].add(Box.createRigidArea(Dimension(0, 20))) self.config_item_dict[key]=UI_key_dict self.pack() pass
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 __init__(self, parentCrate=None): JPanel.__init__(self) self.spy = None self.parentCrate = parentCrate self.nw = 10 # Number of words (total) self.upperPanel = JPanel() self.lowerPanel = JPanel() self.add(self.upperPanel) self.add(self.lowerPanel) self.nameLabel = JLabel("n/a") self.slotLabel = JLabel("n/a") self.textArea = JTextArea("n/a", 1, 70, editable=0) self.scrollPane = JScrollPane(self.textArea) self.textField = JTextField(3, actionCommand="textField", text=("%d" % self.nw)) self.textField.addActionListener(self) self.clearButton = JButton("Stop", actionCommand="button") self.clearButton.addActionListener(self) self.border = BorderFactory.createEmptyBorder(5, 5, 5, 5) self.layout = BoxLayout(self, BoxLayout.Y_AXIS) self.upperPanel.layout = BoxLayout(self.upperPanel, BoxLayout.X_AXIS) self.lowerPanel.layout = BoxLayout(self.lowerPanel, BoxLayout.X_AXIS) self.upperPanel.add(self.clearButton) self.upperPanel.add(Box.createRigidArea(Dimension(20, 0))) self.upperPanel.add(JLabel("Spy:")) self.upperPanel.add(Box.createRigidArea(Dimension(5, 0))) self.upperPanel.add(self.nameLabel) self.upperPanel.add(Box.createRigidArea(Dimension(20, 0))) self.upperPanel.add(JLabel("Slot:")) self.upperPanel.add(Box.createRigidArea(Dimension(5, 0))) self.upperPanel.add(self.slotLabel) self.upperPanel.add(Box.createRigidArea(Dimension(20, 0))) self.upperPanel.add(JLabel("Number of words:")) self.upperPanel.add(Box.createRigidArea(Dimension(5, 0))) self.upperPanel.add(self.textField) self.upperPanel.add(Box.createHorizontalGlue()) self.lowerPanel.add(JLabel("Tail contents:")) self.lowerPanel.add(Box.createRigidArea(Dimension(5, 0))) self.lowerPanel.add(self.scrollPane) self.lowerPanel.add(Box.createHorizontalGlue())
def createMenuBar(manager): global menuHandles, isDominant, isTemporal menuHandles = {} menuBar = JMenuBar() fmenu = JMenu("File") menuHandles['File'] = fmenu fmenu.setMnemonic(KeyEvent.VK_F) menuBar.add(fmenu) fmenu.add(createMenuItem('Open Genepop data', "Open", manager)) fmenu.add(createMenuItem('Use Example data', "Example", manager)) fmenu.addSeparator() fmenu.add(createMenuItem('Citation', "Citation", manager)) fmenu.addSeparator() fmenu.add(createMenuItem("Exit", "Exit", manager)) if not isTemporal: pmenu = JMenu("Populations") menuHandles['Populations'] = pmenu pmenu.setEnabled(False) pmenu.setMnemonic(KeyEvent.VK_P) menuBar.add(pmenu) pmenu.add(createMenuItem('Load population names', "LoadPop", manager)) pmenu.add(createMenuItem('Edit population names', "EditPop", manager)) pmenu.add(createMenuItem('Save population names', "SavePop", manager)) umenu = JMenu("Data used") menuHandles['Data used'] = umenu umenu.setEnabled(False) umenu.setMnemonic(KeyEvent.VK_U) menuBar.add(umenu) umenu.add(createMenuItem('Loci Analyzed', "ChooseLoci", manager)) if isTemporal: umenu.add(createMenuItem('Samples Analyzed', "ChoosePops", manager)) else: umenu.add(createMenuItem('Populations Analyzed', "ChoosePops", manager)) if isDominant: fdmenu = JMenu("DFDist") elif isTemporal: fdmenu = JMenu("FTemp") else: fdmenu = JMenu("FDist") menuHandles['FDist'] = fdmenu fdmenu.setEnabled(False) fdmenu.setMnemonic(KeyEvent.VK_D) menuBar.add(fdmenu) if isTemporal: fdmenu.add(createMenuItem('Run FTemp', "RunFDist", manager)) else: fdmenu.add(createMenuItem('Run FDist', "RunFDist", manager)) item5000 = createMenuItem('Run more 5000 sims', "Run5000", manager) item5000.setEnabled(False) menuHandles['item5000'] = item5000 fdmenu.add(item5000) checkLoci = createMenuItem('Check Loci Status', "CheckLoci", manager) checkLoci.setEnabled(False) menuHandles['checkLoci'] = checkLoci fdmenu.add(checkLoci) gmenu = JMenu("Graphic") gmenu.setEnabled(False) menuHandles['Graphic'] = gmenu gmenu.setMnemonic(KeyEvent.VK_G) menuBar.add(gmenu) gmenu.add(createMenuItem('Colors and loci labels', "ConfGrp", manager)) #gmenu.add(createMenuItem('Save Graphic as PNG', "SavePNG", manager)) gmenu.add(createMenuItem('Save as PNG', "SavePNG", manager)) gmenu.add(createMenuItem('Export as PDF', "SavePDF", manager)) gmenu.add(createMenuItem('Export as SVG', "SaveSVG", manager)) menuBar.add(Box.createHorizontalGlue()) hmenu = JMenu("Help") hmenu.setMnemonic(KeyEvent.VK_H) menuBar.add(hmenu) hmenu.add(createMenuItem('Help', "Help", manager)) return menuBar
def __init__(self, *args, **kwargs): # do not create any class members before calling JFrame.__init__ ! s, size, title, savemode = None, None, None, False self.OKstatus = True if 'settings_config' in kwargs: s = kwargs.pop('settings_config') else: s = None if 'size' in kwargs: size = kwargs.pop('size') else: size = (300, 300) if 'widget' in kwargs: widget = kwargs.pop('widget') else: widget = None if 'savemode' in kwargs: savemode = kwargs.pop('savemode') defaultdir = None if 'defaultdir' in kwargs: defaultdir = kwargs.pop('defaultdir') if len(args) > 0: title = args[0] else: title = 'Save Settings' JFrame.__init__(self, title, size=size, **kwargs) self.widget = widget if self.widget == None: print "Need to pass keyword argument widget=widget when creating SettingsTableFrame" self.s = s self.savemode = savemode self.defaultdir = defaultdir # create FileChooser, make its window bigger and choose smaller font if self.defaultdir != None: self.fc = JFileChooser(self.defaultdir) else: self.fc = JFileChooser() self.fc.setPreferredSize(Dimension(800, 600)) smallfont = Font("Lucida Sans", Font.PLAIN, 12) SetFontRecursively(self.fc.getComponents(), smallfont) filefilter = FileNameExtensionFilter("Settings Files", (DEFAULT_EXTENSION, )) self.fc.setFileFilter(filefilter) # fill the table, in save mode only with the current values, in load mode with current and setting values self.prepare_tabledata() # if not savemode, we first pop up a filechooser to select a loadable setting if self.savemode == False: self.OKstatus = self.load_setting() if not self.OKstatus: return # listener for data edited by user, good for providing PV write access within the table to the user self.dataListener = MyTableModelListener(savemode=self.savemode) self.dataModel.addTableModelListener(self.dataListener) self.table = JTable(self.dataModel) # create Buttons self.bu_do_label = "Save" if self.savemode == True else "Load" self.bu_do_handler = self.bu_save_handler if self.savemode == True else self.bu_load_handler self.bu_do = JButton(self.bu_do_label, actionPerformed=self.bu_do_handler) self.bu_cancel = JButton("Cancel", actionPerformed=self.bu_cancel_handler) # BEGIN visual adaptations of JTable self.table.setRowHeight(24) self.table.getColumnModel().getColumn(0).setMinWidth(200) if self.savemode: self.table.getColumnModel().getColumn(3).setMaxWidth(60) else: self.table.getColumnModel().getColumn(4).setMaxWidth(60) smallfontr = MyTableCellRenderer(font=FONT_FAMILY, style=Font.PLAIN, fontsize=10) smallfontr.setHorizontalAlignment(JLabel.CENTER) bigfontplainr = MyTableCellRenderer(font=FONT_FAMILY, style=Font.PLAIN, fontsize=18) bigfontplainr.setHorizontalAlignment(JLabel.CENTER) bigfontr = MyTableCellRenderer(font=FONT_FAMILY, style=Font.BOLD, fontsize=18) bigfontr.setHorizontalAlignment(JLabel.CENTER) self.table.getColumnModel().getColumn(0).setCellRenderer(smallfontr) self.table.getColumnModel().getColumn(1).setCellRenderer(bigfontplainr) self.table.getColumnModel().getColumn(2).setCellRenderer(bigfontr) if not self.savemode: self.table.getColumnModel().getColumn(3).setCellRenderer(bigfontr) # END visual adaptations of JTable ## BEGIN layout of window (JFrame) self.getContentPane().setLayout(BorderLayout()) self.add(JScrollPane(self.table)) self.bottompanel = JPanel() self.bottompanel.setLayout( BoxLayout(self.bottompanel, BoxLayout.LINE_AXIS)) self.bottompanel.add(Box.createHorizontalGlue()) self.bottompanel.add(self.bu_do) self.bottompanel.add(Box.createRigidArea(Dimension(20, 0))) self.bottompanel.add(self.bu_cancel) self.bottompanel.add(Box.createHorizontalGlue()) self.add(self.bottompanel, BorderLayout.SOUTH)
def __init__(self, parent, title, modal, app): from java.awt import CardLayout self.app = app border = BorderFactory.createEmptyBorder(5, 7, 7, 7) self.getContentPane().setBorder(border) self.setLayout(BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS)) self.FAVAREALAYERNAME = "Favourite zone editing" info = JLabel(self.app.strings.getString("Create_a_new_favourite_zone")) info.setAlignmentX(Component.LEFT_ALIGNMENT) #Name nameLbl = JLabel(self.app.strings.getString("fav_zone_name")) self.nameTextField = JTextField(20) self.nameTextField.setMaximumSize(self.nameTextField.getPreferredSize()) self.nameTextField.setToolTipText(self.app.strings.getString("fav_zone_name_tooltip")) namePanel = JPanel() namePanel.setLayout(BoxLayout(namePanel, BoxLayout.X_AXIS)) namePanel.add(nameLbl) namePanel.add(Box.createHorizontalGlue()) namePanel.add(self.nameTextField) #Country countryLbl = JLabel(self.app.strings.getString("fav_zone_country")) self.countryTextField = JTextField(20) self.countryTextField.setMaximumSize(self.countryTextField.getPreferredSize()) self.countryTextField.setToolTipText(self.app.strings.getString("fav_zone_country_tooltip")) countryPanel = JPanel() countryPanel.setLayout(BoxLayout(countryPanel, BoxLayout.X_AXIS)) countryPanel.add(countryLbl) countryPanel.add(Box.createHorizontalGlue()) countryPanel.add(self.countryTextField) #Type modeLbl = JLabel(self.app.strings.getString("fav_zone_type")) RECTPANEL = "rectangle" POLYGONPANEL = "polygon" BOUNDARYPANEL = "boundary" self.modesStrings = [RECTPANEL, POLYGONPANEL, BOUNDARYPANEL] modesComboModel = DefaultComboBoxModel() for i in (self.app.strings.getString("rectangle"), self.app.strings.getString("delimited_by_a_closed_way"), self.app.strings.getString("delimited_by_an_administrative_boundary")): modesComboModel.addElement(i) self.modesComboBox = JComboBox(modesComboModel, actionListener=self, editable=False) #- Rectangle self.rectPanel = JPanel() self.rectPanel.setLayout(BoxLayout(self.rectPanel, BoxLayout.Y_AXIS)) capturePane = JPanel() capturePane.setLayout(BoxLayout(capturePane, BoxLayout.X_AXIS)) capturePane.setAlignmentX(Component.LEFT_ALIGNMENT) josmP = JPanel() self.captureRBtn = JRadioButton(self.app.strings.getString("capture_area")) self.captureRBtn.addActionListener(self) self.captureRBtn.setSelected(True) self.bboxFromJosmBtn = JButton(self.app.strings.getString("get_current_area"), actionPerformed=self.on_bboxFromJosmBtn_clicked) self.bboxFromJosmBtn.setToolTipText(self.app.strings.getString("get_capture_area_tooltip")) josmP.add(self.bboxFromJosmBtn) capturePane.add(self.captureRBtn) capturePane.add(Box.createHorizontalGlue()) capturePane.add(self.bboxFromJosmBtn) manualPane = JPanel() manualPane.setLayout(BoxLayout(manualPane, BoxLayout.X_AXIS)) manualPane.setAlignmentX(Component.LEFT_ALIGNMENT) self.manualRBtn = JRadioButton(self.app.strings.getString("use_this_bbox")) self.manualRBtn.addActionListener(self) self.bboxTextField = JTextField(20) self.bboxTextField.setMaximumSize(self.bboxTextField.getPreferredSize()) self.bboxTextField.setToolTipText(self.app.strings.getString("fav_bbox_tooltip")) self.bboxTextFieldDefaultBorder = self.bboxTextField.getBorder() self.bboxTextField.getDocument().addDocumentListener(TextListener(self)) manualPane.add(self.manualRBtn) manualPane.add(Box.createHorizontalGlue()) manualPane.add(self.bboxTextField) group = ButtonGroup() group.add(self.captureRBtn) group.add(self.manualRBtn) previewPane = JPanel() previewPane.setLayout(BoxLayout(previewPane, BoxLayout.X_AXIS)) previewPane.setAlignmentX(Component.LEFT_ALIGNMENT) bboxPreviewInfo = JTextField(self.app.strings.getString("coordinates"), editable=0, border=None) bboxPreviewInfo.setMaximumSize(bboxPreviewInfo.getPreferredSize()) self.bboxPreviewTextField = JTextField(20, editable=0, border=None) self.bboxPreviewTextField.setMaximumSize(self.bboxPreviewTextField.getPreferredSize()) previewPane.add(bboxPreviewInfo) previewPane.add(Box.createHorizontalGlue()) previewPane.add(self.bboxPreviewTextField) self.rectPanel.add(capturePane) self.rectPanel.add(Box.createRigidArea(Dimension(0, 10))) self.rectPanel.add(manualPane) self.rectPanel.add(Box.createRigidArea(Dimension(0, 20))) self.rectPanel.add(previewPane) #- Polygon (closed way) drawn by hand self.polygonPanel = JPanel(BorderLayout()) self.polygonPanel.setLayout(BoxLayout(self.polygonPanel, BoxLayout.Y_AXIS)) polyInfo = JLabel("<html>%s</html>" % self.app.strings.getString("polygon_info")) polyInfo.setFont(polyInfo.getFont().deriveFont(Font.ITALIC)) polyInfo.setAlignmentX(Component.LEFT_ALIGNMENT) editPolyPane = JPanel() editPolyPane.setAlignmentX(Component.LEFT_ALIGNMENT) editPolyBtn = JButton(self.app.strings.getString("create_fav_layer"), actionPerformed=self.create_new_zone_editing_layer) editPolyBtn.setToolTipText(self.app.strings.getString("create_fav_layer_tooltip")) editPolyPane.add(editPolyBtn) self.polygonPanel.add(polyInfo) self.polygonPanel.add(Box.createRigidArea(Dimension(0, 15))) self.polygonPanel.add(editPolyPane) self.polygonPanel.add(Box.createRigidArea(Dimension(0, 15))) #- Administrative Boundary self.boundaryPanel = JPanel() self.boundaryPanel.setLayout(BoxLayout(self.boundaryPanel, BoxLayout.Y_AXIS)) boundaryInfo = JLabel("<html>%s</html>" % app.strings.getString("boundary_info")) boundaryInfo.setFont(boundaryInfo.getFont().deriveFont(Font.ITALIC)) boundaryInfo.setAlignmentX(Component.LEFT_ALIGNMENT) boundaryTagsPanel = JPanel(GridLayout(3, 3, 5, 5)) boundaryTagsPanel.setAlignmentX(Component.LEFT_ALIGNMENT) boundaryTagsPanel.add(JLabel("name =")) self.nameTagTextField = JTextField(20) boundaryTagsPanel.add(self.nameTagTextField) boundaryTagsPanel.add(JLabel("admin_level =")) self.adminLevelTagTextField = JTextField(20) self.adminLevelTagTextField.setToolTipText(self.app.strings.getString("adminLevel_tooltip")) boundaryTagsPanel.add(self.adminLevelTagTextField) boundaryTagsPanel.add(JLabel(self.app.strings.getString("other_tag"))) self.optionalTagTextField = JTextField(20) self.optionalTagTextField.setToolTipText("key=value") boundaryTagsPanel.add(self.optionalTagTextField) downloadBoundariesPane = JPanel() downloadBoundariesPane.setAlignmentX(Component.LEFT_ALIGNMENT) downloadBoundariesBtn = JButton(self.app.strings.getString("download_boundary"), actionPerformed=self.on_downloadBoundariesBtn_clicked) downloadBoundariesBtn.setToolTipText(self.app.strings.getString("download_boundary_tooltip")) downloadBoundariesPane.add(downloadBoundariesBtn) self.boundaryPanel.add(boundaryInfo) self.boundaryPanel.add(Box.createRigidArea(Dimension(0, 15))) self.boundaryPanel.add(boundaryTagsPanel) self.boundaryPanel.add(Box.createRigidArea(Dimension(0, 10))) self.boundaryPanel.add(downloadBoundariesPane) self.editingPanels = {"rectangle": self.rectPanel, "polygon": self.polygonPanel, "boundary": self.boundaryPanel} #Main buttons self.okBtn = JButton(self.app.strings.getString("OK"), ImageProvider.get("ok"), actionPerformed=self.on_okBtn_clicked) self.cancelBtn = JButton(self.app.strings.getString("cancel"), ImageProvider.get("cancel"), actionPerformed=self.close_dialog) self.previewBtn = JButton(self.app.strings.getString("Preview_zone"), actionPerformed=self.on_previewBtn_clicked) self.previewBtn.setToolTipText(self.app.strings.getString("preview_zone_tooltip")) okBtnSize = self.okBtn.getPreferredSize() viewBtnSize = self.previewBtn.getPreferredSize() viewBtnSize.height = okBtnSize.height self.previewBtn.setPreferredSize(viewBtnSize) #layout self.add(info) self.add(Box.createRigidArea(Dimension(0, 15))) namePanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(namePanel) self.add(Box.createRigidArea(Dimension(0, 15))) countryPanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(countryPanel) self.add(Box.createRigidArea(Dimension(0, 15))) modeLbl.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(modeLbl) self.add(Box.createRigidArea(Dimension(0, 5))) self.add(self.modesComboBox) self.modesComboBox.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(Box.createRigidArea(Dimension(0, 15))) self.configPanel = JPanel(CardLayout()) self.configPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)) self.configPanel.add(self.rectPanel, RECTPANEL) self.configPanel.add(self.polygonPanel, POLYGONPANEL) self.configPanel.add(self.boundaryPanel, BOUNDARYPANEL) self.configPanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(self.configPanel) buttonsPanel = JPanel() buttonsPanel.add(self.okBtn) buttonsPanel.add(self.cancelBtn) buttonsPanel.add(self.previewBtn) buttonsPanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(buttonsPanel) self.addWindowListener(self) self.pack()
display.addReference(modulesRef) letWidget = LabeledColorWidget(maps.letmap) # align along left side, to match VisADSlider alignment # (if we don't left-align, BoxLayout hoses everything letWidget.setAlignmentX(Component.LEFT_ALIGNMENT) eventWidget = EventWidget(file, amanda, amandaRef, maps.trackmap) widgetPanel = JPanel() widgetPanel.setLayout(BoxLayout(widgetPanel, BoxLayout.Y_AXIS)) widgetPanel.setMaximumSize(Dimension(400, 600)) widgetPanel.add(letWidget) widgetPanel.add(eventWidget) widgetPanel.add(Box.createHorizontalGlue()) displayPanel = display.getComponent() dim = Dimension(800, 800) displayPanel.setPreferredSize(dim) displayPanel.setMinimumSize(dim) # if widgetPanel alignment doesn't match # displayPanel alignment, BoxLayout will freak out widgetPanel.setAlignmentX(displayPanel.getAlignmentX()) widgetPanel.setAlignmentY(displayPanel.getAlignmentY()) # create JPanel in frame panel = JPanel() panel.setLayout(BoxLayout(panel, BoxLayout.X_AXIS))
def __init__(self): self.fields = [ PTTextField( "domain", "Set cookies to be valid for domain: ", cb.demo_domain, None ), PTSeparator(), PTTextField( "phantomJS_path", "Path to PhantomJS binary: ", "/usr/bin/phantomjs", None, JButton( "Browse for binary...", actionPerformed=self._button_browse_pressed ) ), PTTextField( "phantomJS_args", "Optional PhantomJS arguments: ", "--ignore-ssl-errors=true" + " --web-security=false", None, JButton( PhantomJS.uri, actionPerformed=self._button_web_browser_pressed ) ), PTTextField( "url", "Obtain cookies from this URL: ", cb.demo_url, None, JButton( "Open in Browser", actionPerformed=self._button_web_browser_pressed ), JButton( "Send to Repeater", actionPerformed=self._button_repeater_pressed ) ), PTTextField( "duration", "Milliseconds that PhantomJs should wait " + "for cookies to be set: ", "500", None ) ] self.values = {} bordertitle = "Setup a session handling action which uses PhantomJS" +\ " to obtain named cookies to add to Burp's cookie jar" self.setBorder(BorderFactory.createTitledBorder(bordertitle)) self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS)) self._rowpanel1 = JPanel() self._rowpanel1.setLayout(BoxLayout(self._rowpanel1, BoxLayout.Y_AXIS)) self._rowpanel1.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEmptyBorder(), "Settings" ) ) self._rowpanel2 = PTListPanel("Cookies to obtain", [cb.demo_cookie]) self._rowpanel3 = JPanel() self._rowpanel3.setLayout(BoxLayout(self._rowpanel3, BoxLayout.X_AXIS)) self._button_update = JButton( "Add a new \"Get cookies\" session handler " + "with these settings for these cookies", actionPerformed=self._button_update_pressed ) for field in self.fields: self._rowpanel1.add(field) _panel_test = JPanel() _panel_test.add(Box.createHorizontalGlue()) _panel_test.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)) _button_test = JButton( "Verify these settings and fetch cookies now", actionPerformed=self._cookie_fetch_test ) _panel_test.add(_button_test) self._rowpanel1.add(_panel_test) self._rowpanel1.add(PTSeparator()) self._rowpanel3.add(Box.createHorizontalGlue()) self._rowpanel3.add(self._button_update) self.add(self._rowpanel1) self.add(self._rowpanel2) self.add(self._rowpanel3)
def __init__(self): self.profiles = [] self.setBorder( BorderFactory.createTitledBorder("Profiles") ) self.setLayout(BoxLayout(self, BoxLayout.Y_AXIS)) self._rowpanel1 = JPanel() self._rowpanel1.setLayout(BoxLayout(self._rowpanel1, BoxLayout.X_AXIS)) self._profiles_combo = \ JComboBox( self.profiles ) self._profiles_combo.addItem("0"*40) self._profiles_combo.setMaximumSize( self._profiles_combo.getPreferredSize() ) self._profiles_combo.removeItem("0" * 40) self._profiles_combo_panel = border_X_panel() self._demo_panel = button_panel( "Demo", self._button_demo_pressed ) self._quit_panel = button_panel( "Unload WAF Cookie Fetcher", self._button_quit_pressed ) self._profile_textfield = \ PTTextField( "profile", "Profile name: ", "bao7uo WAF bypass", None, JButton( "Save profile", actionPerformed=self._button_save_fields_pressed ) ) self._profiles_combo_panel.add(self._profiles_combo) self._button_delete_profile = \ JButton( "Delete profile", actionPerformed=self._button_delete_profile_pressed ) self._profiles_combo_panel.add(self._button_delete_profile) self._profiles_combo.addActionListener(actionlistener(self)) self._rowpanel1.add(self._profiles_combo_panel) self._rowpanel1.add(Box.createHorizontalGlue()) self._rowpanel1.add(self._profile_textfield) self._rowpanel1.add(Box.createHorizontalGlue()) self._rowpanel1.add(self._demo_panel) self._rowpanel1.add(self._quit_panel) self.add(self._rowpanel1)
def __init__(self, app): from java.awt import Dialog from java.awt import CardLayout JDialog.__init__(self, app.preferencesFrame, app.strings.getString("Create_a_new_favourite_zone"), Dialog.ModalityType.DOCUMENT_MODAL) self.app = app border = BorderFactory.createEmptyBorder(5, 7, 7, 7) self.getContentPane().setBorder(border) self.setLayout(BoxLayout(self.getContentPane(), BoxLayout.Y_AXIS)) self.FAVAREALAYERNAME = "Favourite zone editing" info = JLabel(self.app.strings.getString("Create_a_new_favourite_zone")) info.setAlignmentX(Component.LEFT_ALIGNMENT) #Name nameLbl = JLabel(self.app.strings.getString("fav_zone_name")) self.nameTextField = JTextField(20) self.nameTextField.setMaximumSize(self.nameTextField.getPreferredSize()) self.nameTextField.setToolTipText(self.app.strings.getString("fav_zone_name_tooltip")) namePanel = JPanel() namePanel.setLayout(BoxLayout(namePanel, BoxLayout.X_AXIS)) namePanel.add(nameLbl) namePanel.add(Box.createHorizontalGlue()) namePanel.add(self.nameTextField) #Country countryLbl = JLabel(self.app.strings.getString("fav_zone_country")) self.countryTextField = JTextField(20) self.countryTextField.setMaximumSize(self.countryTextField.getPreferredSize()) self.countryTextField.setToolTipText(self.app.strings.getString("fav_zone_country_tooltip")) countryPanel = JPanel() countryPanel.setLayout(BoxLayout(countryPanel, BoxLayout.X_AXIS)) countryPanel.add(countryLbl) countryPanel.add(Box.createHorizontalGlue()) countryPanel.add(self.countryTextField) #Type modeLbl = JLabel(self.app.strings.getString("fav_zone_type")) RECTPANEL = "rectangle" POLYGONPANEL = "polygon" BOUNDARYPANEL = "boundary" self.modesStrings = [RECTPANEL, POLYGONPANEL, BOUNDARYPANEL] modesComboModel = DefaultComboBoxModel() for i in (self.app.strings.getString("rectangle"), self.app.strings.getString("delimited_by_a_closed_way"), self.app.strings.getString("delimited_by_an_administrative_boundary")): modesComboModel.addElement(i) self.modesComboBox = JComboBox(modesComboModel, actionListener=self, editable=False) #- Rectangle self.rectPanel = JPanel() self.rectPanel.setLayout(BoxLayout(self.rectPanel, BoxLayout.Y_AXIS)) capturePane = JPanel() capturePane.setLayout(BoxLayout(capturePane, BoxLayout.X_AXIS)) capturePane.setAlignmentX(Component.LEFT_ALIGNMENT) josmP = JPanel() self.captureRBtn = JRadioButton(self.app.strings.getString("capture_area")) self.captureRBtn.addActionListener(self) self.captureRBtn.setSelected(True) self.bboxFromJosmBtn = JButton(self.app.strings.getString("get_current_area"), actionPerformed=self.on_bboxFromJosmBtn_clicked) self.bboxFromJosmBtn.setToolTipText(self.app.strings.getString("get_capture_area_tooltip")) josmP.add(self.bboxFromJosmBtn) capturePane.add(self.captureRBtn) capturePane.add(Box.createHorizontalGlue()) capturePane.add(self.bboxFromJosmBtn) manualPane = JPanel() manualPane.setLayout(BoxLayout(manualPane, BoxLayout.X_AXIS)) manualPane.setAlignmentX(Component.LEFT_ALIGNMENT) self.manualRBtn = JRadioButton(self.app.strings.getString("use_this_bbox")) self.manualRBtn.addActionListener(self) self.bboxTextField = JTextField(20) self.bboxTextField.setMaximumSize(self.bboxTextField.getPreferredSize()) self.bboxTextField.setToolTipText(self.app.strings.getString("fav_bbox_tooltip")) self.bboxTextFieldDefaultBorder = self.bboxTextField.getBorder() self.bboxTextField.getDocument().addDocumentListener(TextListener(self)) manualPane.add(self.manualRBtn) manualPane.add(Box.createHorizontalGlue()) manualPane.add(self.bboxTextField) group = ButtonGroup() group.add(self.captureRBtn) group.add(self.manualRBtn) previewPane = JPanel() previewPane.setLayout(BoxLayout(previewPane, BoxLayout.X_AXIS)) previewPane.setAlignmentX(Component.LEFT_ALIGNMENT) bboxPreviewInfo = JTextField(self.app.strings.getString("coordinates"), editable=0, border=None) bboxPreviewInfo.setMaximumSize(bboxPreviewInfo.getPreferredSize()) self.bboxPreviewTextField = JTextField(20, editable=0, border=None) self.bboxPreviewTextField.setMaximumSize(self.bboxPreviewTextField.getPreferredSize()) previewPane.add(bboxPreviewInfo) previewPane.add(Box.createHorizontalGlue()) previewPane.add(self.bboxPreviewTextField) self.rectPanel.add(capturePane) self.rectPanel.add(Box.createRigidArea(Dimension(0, 10))) self.rectPanel.add(manualPane) self.rectPanel.add(Box.createRigidArea(Dimension(0, 20))) self.rectPanel.add(previewPane) #- Polygon (closed way) drawn by hand self.polygonPanel = JPanel(BorderLayout()) self.polygonPanel.setLayout(BoxLayout(self.polygonPanel, BoxLayout.Y_AXIS)) polyInfo = JLabel("<html>%s</html>" % self.app.strings.getString("polygon_info")) polyInfo.setFont(polyInfo.getFont().deriveFont(Font.ITALIC)) polyInfo.setAlignmentX(Component.LEFT_ALIGNMENT) editPolyPane = JPanel() editPolyPane.setAlignmentX(Component.LEFT_ALIGNMENT) editPolyBtn = JButton(self.app.strings.getString("create_fav_layer"), actionPerformed=self.create_new_zone_editing_layer) editPolyBtn.setToolTipText(self.app.strings.getString("create_fav_layer_tooltip")) editPolyPane.add(editPolyBtn) self.polygonPanel.add(polyInfo) self.polygonPanel.add(Box.createRigidArea(Dimension(0, 15))) self.polygonPanel.add(editPolyPane) self.polygonPanel.add(Box.createRigidArea(Dimension(0, 15))) #- Administrative Boundary self.boundaryPanel = JPanel() self.boundaryPanel.setLayout(BoxLayout(self.boundaryPanel, BoxLayout.Y_AXIS)) boundaryInfo = JLabel("<html>%s</html>" % app.strings.getString("boundary_info")) boundaryInfo.setFont(boundaryInfo.getFont().deriveFont(Font.ITALIC)) boundaryInfo.setAlignmentX(Component.LEFT_ALIGNMENT) boundaryTagsPanel = JPanel(GridLayout(3, 3, 5, 5)) boundaryTagsPanel.setAlignmentX(Component.LEFT_ALIGNMENT) boundaryTagsPanel.add(JLabel("name =")) self.nameTagTextField = JTextField(20) boundaryTagsPanel.add(self.nameTagTextField) boundaryTagsPanel.add(UrlLabel("http://wiki.openstreetmap.org/wiki/Key:admin_level#admin_level", "admin_level =")) self.adminLevelTagTextField = JTextField(20) self.adminLevelTagTextField.setToolTipText(self.app.strings.getString("adminLevel_tooltip")) boundaryTagsPanel.add(self.adminLevelTagTextField) boundaryTagsPanel.add(JLabel(self.app.strings.getString("other_tag"))) self.optionalTagTextField = JTextField(20) self.optionalTagTextField.setToolTipText("key=value") boundaryTagsPanel.add(self.optionalTagTextField) downloadBoundariesPane = JPanel() downloadBoundariesPane.setAlignmentX(Component.LEFT_ALIGNMENT) downloadBoundariesBtn = JButton(self.app.strings.getString("download_boundary"), actionPerformed=self.on_downloadBoundariesBtn_clicked) downloadBoundariesBtn.setToolTipText(self.app.strings.getString("download_boundary_tooltip")) downloadBoundariesPane.add(downloadBoundariesBtn) self.boundaryPanel.add(boundaryInfo) self.boundaryPanel.add(Box.createRigidArea(Dimension(0, 15))) self.boundaryPanel.add(boundaryTagsPanel) self.boundaryPanel.add(Box.createRigidArea(Dimension(0, 10))) self.boundaryPanel.add(downloadBoundariesPane) self.editingPanels = {"rectangle": self.rectPanel, "polygon": self.polygonPanel, "boundary": self.boundaryPanel} #Main buttons self.okBtn = JButton(self.app.strings.getString("OK"), ImageProvider.get("ok"), actionPerformed=self.on_okBtn_clicked) self.cancelBtn = JButton(self.app.strings.getString("cancel"), ImageProvider.get("cancel"), actionPerformed=self.close_dialog) self.previewBtn = JButton(self.app.strings.getString("Preview_zone"), actionPerformed=self.on_previewBtn_clicked) self.previewBtn.setToolTipText(self.app.strings.getString("preview_zone_tooltip")) okBtnSize = self.okBtn.getPreferredSize() viewBtnSize = self.previewBtn.getPreferredSize() viewBtnSize.height = okBtnSize.height self.previewBtn.setPreferredSize(viewBtnSize) #layout self.add(info) self.add(Box.createRigidArea(Dimension(0, 15))) namePanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(namePanel) self.add(Box.createRigidArea(Dimension(0, 15))) countryPanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(countryPanel) self.add(Box.createRigidArea(Dimension(0, 15))) modeLbl.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(modeLbl) self.add(Box.createRigidArea(Dimension(0, 5))) self.add(self.modesComboBox) self.modesComboBox.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(Box.createRigidArea(Dimension(0, 15))) self.configPanel = JPanel(CardLayout()) self.configPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)) self.configPanel.add(self.rectPanel, RECTPANEL) self.configPanel.add(self.polygonPanel, POLYGONPANEL) self.configPanel.add(self.boundaryPanel, BOUNDARYPANEL) self.configPanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(self.configPanel) buttonsPanel = JPanel() buttonsPanel.add(self.okBtn) buttonsPanel.add(self.cancelBtn) buttonsPanel.add(self.previewBtn) buttonsPanel.setAlignmentX(Component.LEFT_ALIGNMENT) self.add(buttonsPanel) self.addWindowListener(self) self.pack()
txt.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createLineBorder(Color.red), txt.getBorder())); label_panel_location = JLabel() btnpanelLocation = JButton("Set Panel Location", actionPerformed = btnpanelLocation_action) row0.add(Box.createVerticalGlue()) row0.add(Box.createRigidArea(Dimension(20, 0))) row0.add(btnpanelLocation) row0.add(Box.createRigidArea(Dimension(20, 0))) row0.add(label_panel_location) row0.add(Box.createRigidArea(Dimension(20, 0))) row12 = JPanel() row12.setLayout(BoxLayout(row12, BoxLayout.X_AXIS)) row12b1 = JLabel("Dispatcher System: Modifies panels to produce a running system") row12b1.add( Box.createHorizontalGlue() ); row12b1.setAlignmentX( row12b1.LEFT_ALIGNMENT ) msg = "" row12b2 = JLabel(msg) row12b2.setAlignmentX( row12b1.RIGHT_ALIGNMENT ) row12.add(Box.createVerticalGlue()) row12.add(Box.createRigidArea(Dimension(20, 0))) row12.add(row12b1) row12.add(Box.createRigidArea(Dimension(20, 0))) row12.add(row12b2) row22 = JPanel() row22.setLayout(BoxLayout(row22, BoxLayout.X_AXIS)) row22b1 = JLabel("We Start with the Original Panel") row22b1.add( Box.createHorizontalGlue() );
def drawUI(self): # 最外层:垂直盒子,内放一个水平盒子+一个胶水 out_vBox_main = Box.createVerticalBox() # 次外层:水平盒子,使用说明 usage = u''' JC-AntiToken(简单防重放绕过) 适用场景:防重放的方式为,提前向一个页面发送请求取得token,替换到下一个页面中。 适用说明: 1. 请求头中Headers和Data的值必须是JSON字符串,如:{"var":"value"} 2. 左边tokenRegex的格式为: a. .*开头,.*结尾,用()括住要取出的token b. 如:.*,"token":"(.*?)".* 3. 右边tokenRegex的格式为: a. 需要三个(),第二个()括住要替换的token b. 如:(.*,"token":")(.*?)(".*) 详见:https://github.com/chroblert/JC-AntiToken ''' hBox_usage = Box.createHorizontalBox() jpanel_test = JPanel() jTextarea_usage = JTextArea() jTextarea_usage.setText(usage) jTextarea_usage.setRows(13) jTextarea_usage.setEditable(False) # jpanel_test.add(jTextarea_usage) hBox_usage.add(JScrollPane(jTextarea_usage)) # 次外层:水平盒子,内放两个垂直盒子 hBox_main = Box.createHorizontalBox() # 左垂直盒子 vBox_left = Box.createVerticalBox() # 右垂直盒子 vBox_right = Box.createVerticalBox() # 左垂直盒子内部:发送请求包拿token # URL标签 jlabel_url = JLabel(" URL: ") self.jtext_url = JTextField(generWidth) self.jtext_url.setMaximumSize(self.jtext_url.getPreferredSize()) hbox_url = Box.createHorizontalBox() hbox_url.add(jlabel_url) hbox_url.add(self.jtext_url) hglue_url = Box.createHorizontalGlue() hbox_url.add(hglue_url) # 请求方法标签 jlabel_reqMeth = JLabel("ReqMeth: ") self.jcombobox_reqMeth = JComboBox() self.jcombobox_reqMeth.addItem("GET") self.jcombobox_reqMeth.addItem("POST") hbox_reqMeth = Box.createHorizontalBox() hbox_reqMeth.add(jlabel_reqMeth) hbox_reqMeth.add(self.jcombobox_reqMeth) self.jcombobox_reqMeth.setMaximumSize( self.jcombobox_reqMeth.getPreferredSize()) hglue_reqMeth = Box.createHorizontalGlue() hbox_reqMeth.add(hglue_reqMeth) # ContentType标签 jlabel_contentType = JLabel("ConType: ") self.jcombobox_contentType = JComboBox() self.jcombobox_contentType.addItem("application/json") self.jcombobox_contentType.addItem("application/x-www-form-urlencoded") hbox_contentType = Box.createHorizontalBox() hbox_contentType.add(jlabel_contentType) hbox_contentType.add(self.jcombobox_contentType) self.jcombobox_contentType.setMaximumSize( self.jcombobox_contentType.getPreferredSize()) hglue_contentType = Box.createHorizontalGlue() hbox_contentType.add(hglue_contentType) # Charset标签 jlabel_charset = JLabel("CharSet: ") self.jcombobox_charset = JComboBox() self.jcombobox_charset.addItem("UTF-8") self.jcombobox_charset.addItem("GBK") hbox_charset = Box.createHorizontalBox() hbox_charset.add(jlabel_charset) hbox_charset.add(self.jcombobox_charset) self.jcombobox_charset.setMaximumSize( self.jcombobox_charset.getPreferredSize()) hglue_charset = Box.createHorizontalGlue() hbox_charset.add(hglue_charset) # 请求头标签 jlabel_headers = JLabel("Headers: ") self.jtext_headers = JTextField(generWidth) self.jtext_headers.setMaximumSize( self.jtext_headers.getPreferredSize()) hbox_headers = Box.createHorizontalBox() hbox_headers.add(jlabel_headers) hbox_headers.add(self.jtext_headers) hglue_headers = Box.createHorizontalGlue() hbox_headers.add(hglue_headers) # 请求参数标签 jlabel_data = JLabel(" Data: ") self.jtext_data = JTextField(generWidth) self.jtext_data.setPreferredSize(Dimension(20, 40)) self.jtext_data.setMaximumSize(self.jtext_data.getPreferredSize()) hbox_data = Box.createHorizontalBox() hbox_data.add(jlabel_data) hbox_data.add(self.jtext_data) hglue_data = Box.createHorizontalGlue() hbox_data.add(hglue_data) # token标志位置标签 hbox_radiobtn = Box.createHorizontalBox() jlabel_tokenPosition = JLabel("Token Position: ") self.radioBtn01 = JRadioButton("Header") self.radioBtn02 = JRadioButton("Body") btnGroup = ButtonGroup() btnGroup.add(self.radioBtn01) btnGroup.add(self.radioBtn02) self.radioBtn01.setSelected(True) hbox_radiobtn.add(jlabel_tokenPosition) hbox_radiobtn.add(self.radioBtn01) hbox_radiobtn.add(self.radioBtn02) # token正则表达式标签 hbox_token = Box.createHorizontalBox() hbox_token_header = Box.createHorizontalBox() hbox_token_body = Box.createHorizontalBox() # token正则表达式标签:header中 jlabel_tokenName = JLabel("tokenName: ") self.jtext_tokenName = JTextField(tokenWidth) self.jtext_tokenName.setMaximumSize( self.jtext_tokenName.getPreferredSize()) hbox_token_header.add(jlabel_tokenName) hbox_token_header.add(self.jtext_tokenName) hglue_token_header = Box.createHorizontalGlue() hbox_token_header.add(hglue_token_header) # token正则表达式标签:body中 jlabel_tokenRegex = JLabel("tokenRegex: ") self.jtext_tokenRegex = JTextField(tokenWidth) self.jtext_tokenRegex.setMaximumSize( self.jtext_tokenRegex.getPreferredSize()) hbox_token_body.add(jlabel_tokenRegex) hbox_token_body.add(self.jtext_tokenRegex) hglue_token_body = Box.createHorizontalGlue() hbox_token_body.add(hglue_token_body) # token正则表达式标签 hbox_token.add(hbox_token_header) hbox_token.add(hbox_token_body) # test测试按钮 hbox_test = Box.createHorizontalBox() jbtn_test = JButton("TEST", actionPerformed=self.btnTest) self.jlabel_test = JLabel("Result: ") hbox_test.add(jbtn_test) hbox_test.add(self.jlabel_test) # 水平胶水填充 hGlue_test = Box.createHorizontalGlue() hbox_test.add(hGlue_test) hbox_test.setBorder(BorderFactory.createLineBorder(Color.green, 2)) # 响应数据输出 hbox_resp = Box.createHorizontalBox() self.jtextarea_resp = JTextArea() jsp = JScrollPane(self.jtextarea_resp) hbox_resp.add(self.jtextarea_resp) # 左垂直盒子:添加各种水平盒子 vBox_left.add(hbox_url) vBox_left.add(hbox_reqMeth) vBox_left.add(hbox_contentType) vBox_left.add(hbox_charset) vBox_left.add(hbox_headers) vBox_left.add(hbox_data) vBox_left.add(hbox_radiobtn) vBox_left.add(hbox_token) vBox_left.add(hbox_test) vBox_left.add(hbox_resp) # 左垂直盒子:垂直胶水填充 vGlue_test = Box.createGlue() vBox_left.add(vGlue_test) # 右垂直盒子内部:指定token在请求包中的位置 # token标志位置单选按钮 hbox_radiobtn_r = Box.createHorizontalBox() jlabel_tokenPosition_r = JLabel("Token Position: ") self.radioBtn01_r = JRadioButton("Header") self.radioBtn02_r = JRadioButton("Body") btnGroup_r = ButtonGroup() btnGroup_r.add(self.radioBtn01_r) btnGroup_r.add(self.radioBtn02_r) self.radioBtn01_r.setSelected(True) hbox_radiobtn_r.add(jlabel_tokenPosition_r) hbox_radiobtn_r.add(self.radioBtn01_r) hbox_radiobtn_r.add(self.radioBtn02_r) # token正则表达式 hbox_token_r = Box.createHorizontalBox() hbox_token_header_r = Box.createHorizontalBox() hbox_token_body_r = Box.createHorizontalBox() # token正则表达式:在header中 jlabel_tokenName_r = JLabel("tokenName: ") self.jtext_tokenName_r = JTextField(tokenWidth) self.jtext_tokenName_r.setMaximumSize( self.jtext_tokenName_r.getPreferredSize()) hbox_token_header_r.add(jlabel_tokenName_r) hbox_token_header_r.add(self.jtext_tokenName_r) hglue_token_header_r = Box.createHorizontalGlue() hbox_token_header_r.add(hglue_token_header_r) # token正则表达式:在Body中 jlabel_tokenRegex_r = JLabel("tokenRegex: ") self.jtext_tokenRegex_r = JTextField(tokenWidth) self.jtext_tokenRegex_r.setMaximumSize( self.jtext_tokenRegex_r.getPreferredSize()) hbox_token_body_r.add(jlabel_tokenRegex_r) hbox_token_body_r.add(self.jtext_tokenRegex_r) hglue_token_body_r = Box.createHorizontalGlue() hbox_token_body_r.add(hglue_token_body_r) # token正则表达式 hbox_token_r.add(hbox_token_header_r) hbox_token_r.add(hbox_token_body_r) # 测试按钮 hbox_test_r = Box.createHorizontalBox() jbtn_test_r = JButton("SET", actionPerformed=self.btnTest_r) self.jlabel_test_r = JLabel("Result: ") hbox_test_r.add(jbtn_test_r) hbox_test_r.add(self.jlabel_test_r) # 水平胶水填充 hGlue02 = Box.createHorizontalGlue() hbox_test_r.add(hGlue02) hbox_test_r.setBorder(BorderFactory.createLineBorder(Color.green, 2)) # 右垂直盒子:添加各种水平盒子 vBox_right.add(hbox_radiobtn_r) vBox_right.add(hbox_token_r) vBox_right.add(hbox_test_r) vGlue = Box.createVerticalGlue() vBox_right.add(vGlue) vBox_left.setBorder(BorderFactory.createLineBorder(Color.black, 3)) vBox_right.setBorder(BorderFactory.createLineBorder(Color.black, 3)) # 次外层水平盒子:添加左右两个垂直盒子 hBox_main.add(vBox_left) hBox_main.add(vBox_right) # 最外层垂直盒子:添加次外层水平盒子,垂直胶水 out_vBox_main.add(hBox_usage) out_vBox_main.add(hBox_main) self.mainPanel = out_vBox_main self._callbacks.customizeUiComponent(self.mainPanel) self._callbacks.addSuiteTab(self)
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")
display.addReference(modulesRef) letWidget = LabeledColorWidget(maps.letmap) # align along left side, to match VisADSlider alignment # (if we don't left-align, BoxLayout hoses everything letWidget.setAlignmentX(Component.LEFT_ALIGNMENT) eventWidget = EventWidget(file, amanda, amandaRef, maps.trackmap) widgetPanel = JPanel() widgetPanel.setLayout(BoxLayout(widgetPanel, BoxLayout.Y_AXIS)) widgetPanel.setMaximumSize(Dimension(400, 600)) widgetPanel.add(letWidget) widgetPanel.add(eventWidget) widgetPanel.add(Box.createHorizontalGlue()) displayPanel = display.getComponent() dim = Dimension(800, 800) displayPanel.setPreferredSize(dim) displayPanel.setMinimumSize(dim) # if widgetPanel alignment doesn't match # displayPanel alignment, BoxLayout will freak out widgetPanel.setAlignmentX(displayPanel.getAlignmentX()) widgetPanel.setAlignmentY(displayPanel.getAlignmentY()) # create JPanel in frame panel = JPanel() panel.setLayout(BoxLayout(panel, BoxLayout.X_AXIS))