def run(self): frame = JFrame('Table9', size=(300, 150), locationRelativeTo=None, defaultCloseOperation=JFrame.EXIT_ON_CLOSE) headings = 'T/F,Date,Integer,Float,Double'.split(',') model = myTM(self.data, headings) table = JTable(model, selectionMode=ListSelectionModel.SINGLE_SELECTION) table.getColumnModel().getColumn(model.getColumnCount() - 1 # i.e., last column ).setCellRenderer(myRenderer()) setColumnWidths(table) frame.add(JScrollPane(table)) frame.setVisible(1)
def UI(self): """ User interface for LinkedView """ frame = JFrame("LinkedView") frame.setSize(300, 200) frame.setLayout(GridLayout(4, 1)) link_view = JButton("Link Views", actionPerformed=self.linkView) get_ref = JButton("Update Reference Image", actionPerformed=self.getRef) export_view = JButton("Export Views", actionPerformed=self.exportView) crop_ROIs = JButton("Export Cropped ROIs", actionPerformed=self.saveCroppedROIs) frame.add(link_view) frame.add(get_ref) frame.add(export_view) frame.add(crop_ROIs) frame.setVisible(True)
def run( self ) : self.frame = frame = JFrame( 'CustomDialog', size = ( 200, 100 ), locationRelativeTo = None, defaultCloseOperation = JFrame.EXIT_ON_CLOSE ) self.label = frame.add( JLabel( '' ) ) frame.add( JButton( 'Prompt user', actionPerformed = self.popup ), BorderLayout.SOUTH ) frame.setVisible( 1 )
def run(self): frame = JFrame('Popup1', layout=GridLayout(0, 2), defaultCloseOperation=JFrame.EXIT_ON_CLOSE) frame.add(JLabel('One')) frame.add( JTextField(5, mousePressed=self.PUcheck, mouseReleased=self.PUcheck)) self.PU = self.PUmenu() frame.add(JLabel('Two')) frame.add( JTextField(5, mousePressed=self.PUcheck, mouseReleased=self.PUcheck)) frame.pack() frame.setVisible(1)
def run_update(self): #from javax.swing import JFrame, JButton frame = JFrame("Hello") frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) frame.setLocation(100, 100) frame.setSize(300, 200) def updatePressed(event): jmri.jmrit.signalling.SignallingPanel.updatePressed(ActionEvent)(e) btn = JButton("Add", actionPerformed=updatePressed) frame.add(btn) frame.setVisible(True) btn.doClick frame.dispose()
def run( self ) : frame = JFrame( 'SplitPane3', defaultCloseOperation = JFrame.EXIT_ON_CLOSE ) frame.add( JSplitPane( JSplitPane.VERTICAL_SPLIT, JButton( 'Top' ), JSplitPane( JSplitPane.HORIZONTAL_SPLIT, JButton( 'Left' ), JButton( 'Right' ), ) ) ) frame.pack() frame.setVisible( 1 )
def _open(): frame = JFrame('Galahad', defaultCloseOperation=WindowConstants.EXIT_ON_CLOSE) panel = JPanel(GridLayout(5, 2)) frame.add(panel) chosen_values = {} 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) create_file_choice_button('binary', 'Binary archive:') create_file_choice_button('source', 'Source archive:') create_file_choice_button('output_dir', 'Output directory:') panel.add(JLabel('')) panel.add(JLabel('')) def run_fn(event): log_window = JFrame('Galahad Log') log_text_area = JTextArea() log_text_area.editable = False log_window.setSize(400, 500) log_window.add(log_text_area) log_window.show() log_text_area.append('sdfsdfsdfsdfsd %d' % 3) panel.add(JButton('Run analysis', actionPerformed=run_fn)) panel.add(JButton('Quit', actionPerformed=lambda e: sys.exit(0))) frame.setSize(300, 160) frame.visible = True
def __init__(self, display, widget, width, height, title): from javax.swing import JFrame, JPanel from java.awt import BorderLayout, FlowLayout self.display = display self.panel = JPanel(BorderLayout()) self.panel2 = JPanel(FlowLayout()) self.panel2.add(widget) self.panel.add("North", self.panel2) self.panel.add("Center", self.display.getComponent()) self.frame = JFrame(title, windowClosing=self.desty) self.pane = self.frame.getContentPane() self.pane.add(self.panel) self.frame.setSize(width, height) self.frame.pack() self.frame.show()
def geom_viewer(dsm2file = "dsm2.inp"): """ geom_viewer(dsm2file = "dsm2.inp") starts off a dsm2 geometry viewer for dsm2 input data Irregular xsections are plotted if available otherwise regular xsections are plotted. """ dgv = DSM2GeomViewer(dsm2file) mp = dgv.gui() fr = JFrame() fr.setTitle('Geom Viewer') fr.getContentPane().add(mp) fr.setLocation(300,100) fr.pack() sz = fr.getSize() fr.setSize(250,sz.height) fr.setVisible(1)
def selectExportFile(self, event): parentFrame = JFrame() fileChooser = JFileChooser() fileChooser.setDialogTitle("Specify file to save state") fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY) userSelection = fileChooser.showOpenDialog(parentFrame) if (userSelection == JFileChooser.APPROVE_OPTION): fileLoad = fileChooser.getSelectedFile() filename = fileLoad.getAbsolutePath() self.selectPathText.setText(filename) print 'Filename selected:' + filename self._callbacks.saveExtensionSetting("exportFile", filename) return
def run( self ) : frame = JFrame( 'Table4', size = ( 300, 200 ), locationRelativeTo = None, defaultCloseOperation = JFrame.EXIT_ON_CLOSE ) headings = 'Date,size,Location'.split( ',' ) frame.add( JScrollPane( JTable( myTM( self.data, headings ), selectionMode = ListSelectionModel.SINGLE_SELECTION ) ) ) frame.setVisible( 1 )
def showLoginIdPassword(data): global frame frame = JFrame("Show Id 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("LoginId AND Password") heading.setBounds(200,30,150,40) lbLoginId = JLabel("LoginId") lbPassword = JLabel("password") tfLoginId = JTextField(data[0].encode('ascii')) tfPassword = JTextField(data[1].encode('ascii')) tfLoginId.setEditable(False) tfPassword.setEditable(False) lbLoginId.setBounds(50,100,150,30) lbPassword.setBounds(50,150,150,30) tfLoginId.setBounds(220,100,150,30) tfPassword.setBounds(220,150,150,30) btnOk = JButton("Ok",actionPerformed=clickOk) btnOk.setBounds(250,220,100,30) panel.add(heading) panel.add(lbLoginId) panel.add(lbPassword) panel.add(tfLoginId) panel.add(tfPassword) panel.add(btnOk) frame.add(panel)
def run(self): d = 0 LGE = GraphicsEnvironment.getLocalGraphicsEnvironment() for GD in LGE.getScreenDevices(): # foreach ScreenDevice... for GC in GD.getConfigurations(): # GraphicConfiguration b = GC.getBounds() # virtual bounds w = int(b.getWidth()) >> 1 # 1/2 screen width h = int(b.getHeight()) >> 3 # 1/8 screen height x = int((int(b.getWidth() - w) >> 1) + b.getX()) y = int((int(b.getHeight() - h) >> 1) + b.getY()) frame = JFrame( 'Screen: %d' % d, # d == Device # 0..N bounds=(x, y, w, h), defaultCloseOperation=JFrame.EXIT_ON_CLOSE) d += 1 frame.add(JLabel( ` GC `)) frame.setVisible(1)
def run( self ) : self.frame = frame = JFrame( 'SecConfigReport_12', size = ( 500, 300 ), locationRelativeTo = None, componentResized = self.frameResized, defaultCloseOperation = JFrame.EXIT_ON_CLOSE ) #----------------------------------------------------------------------- # Add our menu bar to the frame #----------------------------------------------------------------------- frame.setJMenuBar( self.MenuBar() ) data = [] text = AdminTask.generateSecConfigReport() #----------------------------------------------------------------------- # The RegExp was added to replace multiple blanks with a single one #----------------------------------------------------------------------- for line in text.splitlines()[ 2: ] : data.append( [ re.sub( ' +', ' ', info.strip() ) for info in line[ :-2 ].split( ';' ) ] ) self.table = table = JTable( reportTableModel( data, ';;;'.split( ';' ), ), autoCreateRowSorter = 1, selectionMode = ListSelectionModel.SINGLE_SELECTION ) for key in 'UP,DOWN,PAGE_UP,PAGE_DOWN,ctrl END'.split( ',' ) : upDownAction( table, key ) table.setDefaultRenderer( String, reportRenderer() ) self.setColumnWidths( table ) scroller = JScrollPane( table ) frame.add( scroller ) frame.pack() frame.setVisible( 1 ) frame.setMinimumSize( frame.getSize() )
def run(self): #----------------------------------------------------------------------- # Create and set up the window. #----------------------------------------------------------------------- frame = JFrame('GlassPaneDemo') frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) #----------------------------------------------------------------------- # Start creating and adding components. #----------------------------------------------------------------------- changeButton = JCheckBox('Glass pane "visible"') changeButton.setSelected(0) #----------------------------------------------------------------------- # Set up the content pane, where the 'main GUI' lives. #----------------------------------------------------------------------- contentPane = frame.getContentPane() contentPane.setLayout(FlowLayout()) contentPane.add(changeButton) contentPane.add(JButton('Button 1')) contentPane.add(JButton('Button 2')) #----------------------------------------------------------------------- # Set up the menu bar, which appears above the content pane. #----------------------------------------------------------------------- menuBar = JMenuBar() menu = JMenu('Menu') menu.add(JMenuItem('Do nothing')) menuBar.add(menu) frame.setJMenuBar(menuBar) #----------------------------------------------------------------------- # Set up the glass pane, which appears over both menu bar and # content pane and is an item listener on the change button #----------------------------------------------------------------------- myGlassPane = MyGlassPane(changeButton, menuBar, contentPane) changeButton.addItemListener(myGlassPane) frame.setGlassPane(myGlassPane) #----------------------------------------------------------------------- # Resize the frame to display the visible components contain therein, # and have the frame (application) make itself visisble. #----------------------------------------------------------------------- frame.pack() frame.setVisible(1)
def create_gui(): global dropdown, current_file frame = JFrame('', defaultCloseOperation = JFrame.DISPOSE_ON_CLOSE, size = (400, 150)); frame.setBounds(350,350,400,150); container_panel = JPanel(GridBagLayout()); c = GridBagConstraints(); dropdown = JComboBox(list(img_paths.keys())); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; c.weightx = 0.5; c.gridwidth = 3; container_panel.add(dropdown, c); add_file_button = JButton('<html>Add Image/File</html>', actionPerformed=select_file); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 3; c.gridy = 0; c.weightx = 0.5; c.gridwidth = 1; container_panel.add(add_file_button, c); process_file_button = JButton('<html>Process Selected Image</html>', actionPerformed=process_current_img); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 1; c.weightx = 0.5; c.gridwidth = 2; container_panel.add(process_file_button, c); process_all_button = JButton('<html>Process Entire Stack</html>', actionPerformed=process_stack); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 2; c.gridy = 1; c.weightx = 0.5; c.gridwidth = 2; container_panel.add(process_all_button, c); current_file = dropdown.getSelectedItem(); frame.add(container_panel); frame.visible = True;
def __init__(self, delay): self.frame = JFrame("SVT Monitor", \ windowClosing = lambda event: sys.exit(0)) self.grid = GridLayout(2, 4) self.pane = self.frame.contentPane self.pane.layout = self.grid self.buttonList = map(lambda x: JButton("b0svt0" + `x`), \ [0,7,6,5,1,2,3,4]) # Left to right, # top to bottom for button in self.buttonList: button.actionCommand = button.text button.addActionListener(self) self.pane.add(button) self.crateMonitorList = [] self.frame.pack() self.frame.visible = 1 self.timer = Timer(delay, self) self.timer.start()
def run(self): frame = JFrame('BorderLayoutGap', layout=BorderLayout(16, 8), defaultCloseOperation=JFrame.EXIT_ON_CLOSE) data = [ BorderLayout.NORTH, BorderLayout.SOUTH, BorderLayout.EAST, BorderLayout.WEST ] for pos in data: frame.add(JButton(pos), pos) big = JButton('Center', preferredSize=Dimension(256, 128)) frame.add(big, BorderLayout.CENTER) frame.pack() frame.setVisible(1)
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 run(self): frame = JFrame('Menu3', size=(200, 125), defaultCloseOperation=JFrame.EXIT_ON_CLOSE) menuBar = JMenuBar(background=Color.blue) # print '\nmenuBar size before:', menuBar.getPreferredSize() fileMenu = JMenu('File', foreground=Color.white) fileMenu.add(JMenuItem('Exit')) menuBar.add(fileMenu) # print 'menuBar size after:', menuBar.getPreferredSize() helpMenu = JMenu('Help', foreground=Color.white) helpMenu.add(JMenuItem('About')) menuBar.add(helpMenu) frame.setJMenuBar(menuBar) frame.setVisible(1)
def gui(self): # Hilfsfunktion für event # erstellt ein Rezeptobjekt anhand einer URL # schließt die GUI def create(event): url = field.getText() self.recipe = Recipe(url) frame.dispose() print("created recipe for " + self.recipe.get_title()) # der Dialog wartet, bis "continue" gesendet wird self.send("continue") # Frame erstellen frame = JFrame( 'URL eingeben', defaultCloseOperation=JFrame.EXIT_ON_CLOSE, size=(480, 200), ) frame.setLayout(None) # Text im Frame fieldlabel = JLabel() fieldlabel.setText( "<html><font size=+1>Geben Sie die Internetadresse des Rezepts ein</font></html>" ) fieldlabel.setBounds(20, 20, 500, 40) frame.add(fieldlabel) # Textfeld im Frame field = JTextField() field.setText("https://www.chefkoch.de/rezepte/...") field.setBounds(20, 60, 411, 40) frame.add(field) # Button im Frame # ruft Hilfsfunktion create auf button = JButton("Los!", actionPerformed=create) button.setBounds(155, 100, 150, 30) frame.add(button) #Frame anzeigen frame.setVisible(True)
def __init__(self, game): self.frame = JFrame("Tic Tac Toe", defaultCloseOperation = WindowConstants.EXIT_ON_CLOSE) self.panel = JPanel(GridLayout(3,3)) self.buttons = [] self.game = game for row in range(3): for col in range(3): self.buttons.append(TicTacButton(row,col,'',actionPerformed=self.clicked_button)) self.panel.add self.frame.add(self.panel) for b in self.buttons: self.panel.add(b) self.frame.pack() self.show()
def __init__(self, filename, width=None, height=None): """Create an image from a file, or an empty (black) image with specified dimensions.""" # Since Python does not allow constructors with different signatures, # the trick is to reuse the first argument as a filename or a width. # If it is a string, we assume they want is to open a file. # If it is an int, we assume they want us to create a blank image. if type(filename) == type(""): # is it a string? self.filename = filename # treat is a filename self.image = BufferedImage( 1, 1, BufferedImage.TYPE_INT_RGB) # create a dummy image self.read(filename) # and read external image into ti elif type(filename) == type(1): # is it a int? # create blank image with specified dimensions self.filename = "Untitled" self.width = filename # holds image width (shift arguments) self.height = width # holds image height self.image = BufferedImage( self.width, self.height, BufferedImage.TYPE_INT_RGB) # holds image buffer (pixels) else: raise TypeError( "Image(): first argument must a filename (string) or an blank image width (int)." ) # display image self.display = JFrame() # create frame window to hold image icon = ImageIcon( self.image) # wrap image appropriately for displaying in a frame container = JLabel(icon) self.display.setContentPane(container) # and place it self.display.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) self.display.setTitle(self.filename) self.display.setResizable(False) self.display.pack() self.display.setVisible(True) # remember that this image has been created and is active (so that it can be stopped/terminated by JEM, if desired) _ActiveImages_.append(self)
def __private_init__(self, text="Property Editor", columns=None, data=None, empty=None, add_actions=True, actions=None): if not actions: actions = [] if not columns: columns = [] if data == None: data = [] if not empty: empty = [] self._text = text self.this = JFrame(text) self._table = JTable() self._dtm = DefaultTableModel(0, 0) self._dtm.setColumnIdentifiers(columns) self._table.setModel(self._dtm) self._data = data for d in data: self._dtm.addRow(d) self._pane = JScrollPane(self._table) self.this.add(self._pane) self._empty = empty self.this.addWindowListener(self) self._dtm.addTableModelListener(lambda _: self._update_model()) self.this.setLocation(PropertyEditor.NEW_WINDOW_OFFSET, PropertyEditor.NEW_WINDOW_OFFSET) if add_actions: self._popup = JPopupMenu() self._pane.setComponentPopupMenu(self._popup) inherits_popup_menu(self._pane) self._actions = actions self._actions.append(ExecutorAction('Remove Selected Rows', action=lambda e: self._remove_row())) self._actions.append(ExecutorAction('Add New Row', action=lambda e: self._add_row())) for action in self._actions: self._popup.add(action.menuitem) self.this.setForeground(Color.black) self.this.setBackground(Color.lightGray) self.this.pack() self.this.setVisible(True) self.this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE) return self
def run(self): frame = JFrame('Menu4', size=(200, 125), defaultCloseOperation=JFrame.EXIT_ON_CLOSE) menuBar = JMenuBar() fileMenu = JMenu('File') exitItem = fileMenu.add(JMenuItem('Exit', actionPerformed=self.exit)) menuBar.add(fileMenu) helpMenu = JMenu('Help') aboutItem = helpMenu.add(JMenuItem('About', actionPerformed=self.about)) menuBar.add(helpMenu) frame.setJMenuBar(menuBar) frame.setVisible(1)
def run( self ) : frame = JFrame( 'EditableComboBox', size = ( 210, 100 ), layout = FlowLayout(), defaultCloseOperation = JFrame.EXIT_ON_CLOSE ) frame.add( JLabel( 'Pick one:' ) ) self.choices = 'The,quick,brown,fox,jumped'.split( ',' ) self.choices.extend( 'over,the,lazy,spam'.split( ',' ) ) ComboBox = frame.add( JComboBox( self.choices, editable = 1 ) ) ComboBox.addActionListener( self ) self.msg = frame.add( JLabel() ) frame.setVisible( 1 )
def startGui(self): frame = JFrame("Life", defaultCloseOperation=JFrame.EXIT_ON_CLOSE) (R, C) = (self.numRows, self.numCols) gridPanel = JPanel(GridLayout(R, C)) self.checkBoxes = [[JCheckBox() for c in range(C)] for r in range(R)] self.grid = [[False for c in range(C)] for r in range(R)] for r in range(R): for c in range(C): gridPanel.add(self.checkBoxes[r][c]) frame.add(gridPanel) buttonPanel = JPanel(FlowLayout()) stepButton = JButton("Step", actionPerformed=self._step) runButton = JToggleButton("Run", actionPerformed=self._run) buttonPanel.add(stepButton) buttonPanel.add(runButton) frame.add(buttonPanel, SOUTH) frame.pack() frame.locationRelativeTo = None frame.visible = True
def helpMenu(self, event): self._helpPopup = JFrame('JWT Fuzzer', size=(550, 450)) self._helpPopup.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) helpPanel = JPanel() helpPanel.setPreferredSize(Dimension(550, 450)) helpPanel.setBorder(EmptyBorder(10, 10, 10, 10)) helpPanel.setLayout(BoxLayout(helpPanel, BoxLayout.Y_AXIS)) self._helpPopup.setContentPane(helpPanel) helpHeadingText = JLabel("<html><h2>JWT Fuzzer</h2></html>") authorText = JLabel("<html><p>@author: <pinnace></p></html>") aboutText = JLabel( "<html><br /> <p>This extension adds an Intruder payload processor for JWTs.</p><br /></html>" ) repositoryText = JLabel("<html>Documentation and source code:</html>") repositoryLink = JLabel( "<html>- <a href=\"https://github.com/pinnace/burp-jwt-fuzzhelper-extension\">https://github.com/pinnace/burp-jwt-fuzzhelper-extension</a></html>" ) licenseText = JLabel( "<html><br/><p>JWT Fuzzer uses a GPL 3 license. This license does not apply to the dependency below:<p></html>" ) dependencyLink = JLabel( "<html>- <a href=\"https://github.com/jpadilla/pyjwt/blob/master/LICENSE\">pyjwt</a></html>" ) dependencyLink.addMouseListener(ClickListener()) dependencyLink.setCursor(Cursor.getPredefinedCursor( Cursor.HAND_CURSOR)) repositoryLink.addMouseListener(ClickListener()) repositoryLink.setCursor(Cursor.getPredefinedCursor( Cursor.HAND_CURSOR)) helpPanel.add(helpHeadingText) helpPanel.add(authorText) helpPanel.add(aboutText) helpPanel.add(repositoryText) helpPanel.add(repositoryLink) helpPanel.add(licenseText) helpPanel.add(dependencyLink) self._helpPopup.setSize(Dimension(550, 450)) self._helpPopup.pack() self._helpPopup.setLocationRelativeTo(None) self._helpPopup.setVisible(True) return
def getCourseName(check): global frame global tfStudentCourseChoice global value value = check frame = JFrame("Course Name ") frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) frame.setSize(500,250) frame.setLocation(200,200) frame.setLayout(None) frame.setVisible(True) panel = JPanel() panel.setSize(500,250) panel.setLocation(0,0) panel.setLayout(None) panel.setVisible(True) panel.setBackground(Color.LIGHT_GRAY) heading = JLabel("Get Course Name") heading.setBounds(200,30,150,40) lbStudentCourseChoice = JLabel("Student course name") tfStudentCourseChoice = JTextField() lbStudentCourseChoice.setBounds(50,70,150,30) tfStudentCourseChoice.setBounds(220,70,150,30) btnEnter = JButton("Enter",actionPerformed=clickStudentCourseChoice) btnCancel = JButton("Cancel",actionPerformed=clickBtnCancel) btnEnter.setBounds(350,150,100,30) btnCancel.setBounds(50,150,100,30) panel.add(heading) panel.add(lbStudentCourseChoice) panel.add(tfStudentCourseChoice) panel.add(btnEnter) panel.add(btnCancel) frame.add(panel)
def run( self ) : self.frame = frame = JFrame( 'Frame3', size = ( 200, 200 ), layout = None, locationRelativeTo = None, defaultCloseOperation = JFrame.EXIT_ON_CLOSE ) frame.addComponentListener( listener( self ) ) self.width = JTextField( 4, actionPerformed = self.changeWidth ) self.height = JTextField( 4, actionPerformed = self.changeHeight ) self.x = JTextField( 4, actionPerformed = self.changeX ) self.y = JTextField( 4, actionPerformed = self.changeY ) items = [ [ JLabel( 'Width:' ) , 11, 7 ], [ self.width , 50, 5 ], [ JLabel( 'Height:' ), 7, 31 ], [ self.height , 50, 30 ], [ JLabel( 'X:' ) , 35, 55 ], [ self.x , 50, 53 ], [ JLabel( 'Y:' ) , 35, 79 ], [ self.y , 50, 78 ] ] for item in items : thing = frame.add( item[ 0 ] ) size = thing.getPreferredSize() thing.setBounds( item[ 1 ], item[ 2 ], size.width, size.height ) frame.setVisible( 1 )