def test_tb_across_threads(self): if not test_support.is_jython: return # http://bugs.jython.org/issue1533624 class PyRunnable(Runnable): def run(self): raise TypeError('this is only a test') try: EventQueue.invokeAndWait(PyRunnable()) except TypeError: self.assertEqual(tb_info(), [('test_tb_across_threads', 'EventQueue.invokeAndWait(PyRunnable())'), ('run', "raise TypeError('this is only a test')")]) else: self.fail('Expected TypeError')
border=BorderFactory.createTitledBorder('Layered Pane'), preferredSize=Dimension(290, 280)) position, level = Point(10, 20), 0 for name, color in colors: label = self.createColoredLabel('Layer %d = %s' % (level, name), color) label.setLocation(position) position.x += 20 position.y += 20 result.add(label, level, 0) # result.add( label, level ) # print level, result.getLayer( label ), result.getPosition( label ) level += 1 return result #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(LayeredPaneDemo()) if 'AdminConfig' in dir(): raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script should be executed, not imported.\n' which = ['wsadmin -f', 'jython']['JYTHON_JAR' in dir(sys)] print 'Usage: %s %s.py' % (which, __name__) sys.exit()
box.add(JLabel('<---- Top ---->')) box.add(Box.createVerticalStrut(5)) box.add(JSeparator()) box.add(Box.createVerticalStrut(5)) box.add(JLabel('<---- Mid ---->')) box.add(Box.createVerticalStrut(5)) box.add(JSeparator()) box.add(Box.createVerticalStrut(5)) box.add(JLabel('<---- Bot ---->')) box.add(Box.createGlue()) frame.add(box) frame.pack() frame.setVisible(1) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(vBox()) if 'AdminConfig' in dir(): raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script should be executed, not imported.\n' which = ['wsadmin -f', 'jython']['JYTHON_JAR' in dir(sys)] print 'Usage: %s %s.py' % (which, __name__) sys.exit()
col.setMaxWidth(cWidth + margin) #------------------------------------------------------------------- # Add current column (preferred) width to the total table width #------------------------------------------------------------------- tWidth += col.getPreferredWidth() #----------------------------------------------------------------------- # Set the preferred viewport size #----------------------------------------------------------------------- table.setPreferredScrollableViewportSize( Dimension(tWidth, 24 * table.getRowHeight())) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: if 'AdminConfig' in dir(): EventQueue.invokeLater(SecConfigReport_09()) raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script requires a WebSphere environment.' print 'Usage: wsadmin -f SecConfigReport_09.py' else: print '\nError: This script should be executed, not imported.\n' print 'Usage: wsadmin -f %s.py' % __name__ sys.exit()
tab2 = JPanel() for name in 'A,B,C'.split(','): tab2.add(JButton(name)) tab3 = JPanel() tab3.add(JLabel('Now is the time for all good men to come to...')) tabs = JTabbedPane() tabs.addTab('Uno', tab1) tabs.addTab('Dos', tab2) tabs.addTab('Tres', tab3) container.add(tabs) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(TabbedPaneDemo()) if 'AdminConfig' in dir(): raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script should be executed, not imported.\n' which = ['wsadmin -f', 'jython']['JYTHON_JAR' in dir(sys)] print 'Usage: %s %s.py' % (which, __name__) sys.exit()
'creating the TuningParams object.' else: try: AdminConfig.modify(self.tuningParms, [['invalidationTimeout', value]]) AdminConfig.save() text = 'Update successful.' except: text = 'A problem was encountered while ' + \ 'updating the TuningParams object.' self.message.setText(text) #------------------------------------------------------------------------------- # Role: main entry point - verify that the script was executed, not imported. # Note: wsadmin in WebSphere Application Server v 6.1 uses 'main', not '__main__' # However, it is important to note that the version of Jython that is # provided with WSAS V 6.1 does not include the SwingWorker class #------------------------------------------------------------------------------- if __name__ == '__main__': if 'AdminConfig' in dir(): EventQueue.invokeLater(consoleTimeout_02()) raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script requires the WebSphere Application Server product.' print 'Usage: wsadmin -f consoleTimeout_02.py' else: print '\nError: This script should be executed, not imported.\n' print 'Usage: wsadmin -f %s.py' % __name__ sys.exit()
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) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(Table9()) if 'AdminConfig' in dir(): raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script should be executed, not imported.\n' which = ['wsadmin -f', 'jython']['JYTHON_JAR' in dir(sys)] print 'Usage: %s %s.py' % (which, __name__) sys.exit()
#--------------------------------------------------------------------------- # Name: remove() # Role: Event handler associated withe the "Remove" button #--------------------------------------------------------------------------- def remove(self, event): cb = self.ComboBox index = cb.getSelectedIndex() item = cb.getSelectedItem() try: cb.removeItem(item) self.msg.setText('Item removed: "%s"' % item) except: self.msg.setText('Remove request failed') self.RemoveButton.setEnabled(cb.getItemCount() > 1) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(DynamicComboBox()) if 'AdminConfig' in dir(): raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script should be executed, not imported.\n' which = ['wsadmin -f', 'jython']['JYTHON_JAR' in dir(sys)] print 'Usage: %s %s.py' % (which, __name__) sys.exit()
# Role: Demonstrate use of JColorChooser #--------------------------------------------------------------------------- def showCC(self, event): result = JColorChooser().showDialog( None, # Parent component 'Color Selection', # Dialog title self.label.getForeground() # Initial color ) if result: message = 'New color: "%s"' % result.toString() self.label.setForeground(result) else: message = 'Request canceled by user' self.label.setText(message) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(ColorChooserDemo()) if 'AdminConfig' in dir(): raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script should be executed, not imported.\n' which = ['wsadmin -f', 'jython']['JYTHON_JAR' in dir(sys)] print 'Usage: %s %s.py' % (which, __name__) sys.exit()
frame = JFrame('ButtonDemo_04', defaultCloseOperation=JFrame.EXIT_ON_CLOSE) frame.add(JButton('Press me', actionPerformed=self.buttonPressed)) self.label = JLabel('button press pending') frame.add(self.label, BorderLayout.SOUTH) frame.pack() frame.setVisible(1) #--------------------------------------------------------------------------- # Name: buttonPressed() # Role: Invoked when the associated button is pressed #--------------------------------------------------------------------------- def buttonPressed(self, e): self.label.text = 'button pressed' #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(ButtonDemo_04a()) if 'AdminConfig' in dir(): raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script should be executed, not imported.\n' which = ['wsadmin -f', 'jython']['JYTHON_JAR' in dir(sys)] print 'Usage: %s %s.py' % (which, __name__) sys.exit()
# # Role: Demonstrate the 7 argument showInputDialog() method call # #--------------------------------------------------------------------------- # def showID( self, event ) : # COLORS = 'Red,Orange,Yellow,Green,Blue,Indigo,Violet' # colors = COLORS.split( ',' ) # result = JOptionPane.showInputDialog( # self.frame, # parentComponent # 'What is your favorite color?', # message text # 'Asked by the bridge guardian', # title # JOptionPane.QUESTION_MESSAGE, # messageType # None, # icon # colors, # selectionValues # colors[ -1 ] # initialSelectionValue # ) # self.label.setText( 'result = "%s"' % result ) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(OptionDialogDemo()) if 'AdminConfig' in dir(): raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script should be executed, not imported.\n' which = ['wsadmin -f', 'jython']['JYTHON_JAR' in dir(sys)] print 'Usage: %s %s.py' % (which, __name__) sys.exit()
pane.setDividerLocation(300) node = self.tree.getLastSelectedPathComponent() # Check if node is root. If it is, don't display anything if node is None or node.getParent() is None: return test_name = node.toString() functionality_name = node.getParent().toString() is_leaf = node.isLeaf() is_settings = is_leaf and (test_name == "Settings") is_folder = is_leaf and (test_name == "Functionality") is_functionality = is_leaf and not is_settings if node: if is_functionality: key = functionality_name + "." + test_name tabbed_pane = self.tabbed_panes[key] pane.setRightComponent(tabbed_pane) elif is_settings: pane.setRightComponent(self.settings) else: print("No description for " + test_name) else: print("Cannot set a pane for " + test_name) if __name__ in ('__main__', 'main'): EventQueue.invokeLater(Run(BurpExtender))
# Role: Instantiate the user class # Note: Invoked by the Swing Event Dispatch Thread #--------------------------------------------------------------------------- def run(self): frame = JFrame('JSpinnerDemo', layout=FlowLayout(), defaultCloseOperation=JFrame.EXIT_ON_CLOSE) daysOfWeek = [dow for dow in DFS().getWeekdays() if dow] width = max([len(dow) for dow in daysOfWeek]) spinner = JSpinner(SpinnerListModel(daysOfWeek)) spinner.getEditor().getTextField().setColumns(width) frame.add(spinner) frame.pack() frame.setVisible(1) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(JSpinnerDemo()) if 'AdminConfig' in dir(): raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script should be executed, not imported.\n' which = ['wsadmin -f', 'jython']['JYTHON_JAR' in dir(sys)] print 'Usage: %s %s.py' % (which, __name__) sys.exit()
self.view.unlock() elif (code == KeyEvent.VK_E): nbrActor = self.view.GetRenderer().GetNumberOfPropsRendered() print("Number of actors rendered : " + str(nbrActor)) print("Number of actors : " + str(self.view.GetRenderer().GetViewProps().GetNumberOfItems())) elif code == KeyEvent.VK_P: print self.view.GetRenderer().GetActiveCamera() canvas.addKeyListener(MyKeyListener(canvas)) style = vtkInteractorStyleTrackballCamera() style.AutoAdjustCameraClippingRangeOn() canvas.getIren().SetInteractorStyle(style) # Run these commands in the Event Dispatch Thread, otherwise an # IllegalMonitorStateException may be raised. class RunInEventDispatchThread(Thread): def __init__(self, frame, canvas): self.frame = frame self.canvas = canvas def run(self): self.frame.setVisible(True) self.canvas.cameraManager.fitAll() EventQueue.invokeLater(RunInEventDispatchThread(frame, canvas)) if options.batch: Utils.takeScreenshot(canvas, options.batch) sys.exit(0)
c0 = w0 + margin c1 = int(width - c0 - margin) tcr = table.getCellRenderer(0, 0) tcr.setWidths(c0, c1) tcr.setHiText(hiText) tcm.getColumn(0).setPreferredWidth(c0) tcm.getColumn(1).setPreferredWidth(c1) except: Type, value = sys.exc_info()[:2] Type, value = str(Type), str(value) if not (Type.endswith('KeyError') and value == 'wsadmin'): print '\nError: %s\nvalue: %s' % (Type, value) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: if 'AdminConfig' in dir(): EventQueue.invokeLater(WSAShelp_09()) raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script requires a WebSphere environment.' print 'Usage: wsadmin -f WSAShelp_09.py' else: print '\nError: This script should be executed, not imported.\n' print 'Usage: wsadmin -f %s.py' % __name__ sys.exit()
print('No mode') def checkPos(self,event): global mode mode = 0 mouseMove(check_pos) def getCurrentPos(self, event): global mode print('Start to Get mouse pos') mode = 4 Thread.sleep(3000) print('Get mouse pos') mouse_pos = Env.getMouseLocation() print('Current mouse pos: x:' + mouse_pos.x + ' y:' + mouse_pos.y) def stop(self, event): if self.timer: self.timer.cancel() self.frame.dispose() self.dispose() def __del__(self): if self.timer: self.timer.cancel() print('Deconstructor') if __name__ == '__main__': EventQueue.invokeLater(MainFrame())
choices.extend('over,the,lazy,spam'.split(',')) ComboBox = frame.add(JComboBox(choices)) ComboBox.addActionListener(self) self.msg = frame.add(JLabel()) frame.setVisible(1) #--------------------------------------------------------------------------- # Name: actionPerformed() # Role: ActionListener Event handler for the JComboBox #--------------------------------------------------------------------------- def actionPerformed(self, event): ComboBox = event.getSource() msg = 'Selection: ' + ComboBox.getSelectedItem() self.msg.setText(msg) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(ComboBoxDemo()) if 'AdminConfig' in dir(): raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script should be executed, not imported.\n' which = ['wsadmin -f', 'jython']['JYTHON_JAR' in dir(sys)] print 'Usage: %s %s.py' % (which, __name__) sys.exit()
# Name: buttonPress() # Role: Event handler #--------------------------------------------------------------------------- def buttonPress( self, event ) : dir, size = event.getActionCommand().split( ' ' ) if dir[ 0 ] == 'H' : for pane in self.panes : layout = pane.getLayout() layout.setHgap( int( size ) ) layout.layoutContainer( pane ) else : for pane in self.panes : layout = pane.getLayout() layout.setVgap( int( size ) ) layout.layoutContainer( pane ) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in [ '__main__', 'main' ] : EventQueue.invokeLater( GridLayoutDemo() ) if 'AdminConfig' in dir() : raw_input( '\nPress <Enter> to terminate the application:\n' ) else : print '\nError: This script should be executed, not imported.\n' which = [ 'wsadmin -f', 'jython' ][ 'JYTHON_JAR' in dir( sys ) ] print 'Usage: %s %s.py' % ( which, __name__ ) sys.exit()
) return pane #--------------------------------------------------------------------------- # Name: resize() # Role: ActionListener actionPerformed event handler for divider resizing #--------------------------------------------------------------------------- def resize( self, event ) : sizes = { 'Small' : 0, 'Medium' : 10, 'Large' : 20 } name = event.getActionCommand() self.sp.setDividerSize( sizes[ name ] ) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in [ '__main__', 'main' ] : EventQueue.invokeLater( SplitPane5() ) if 'AdminConfig' in dir() : raw_input( '\nPress <Enter> to terminate the application:\n' ) else : print '\nError: This script should be executed, not imported.\n' which = [ 'wsadmin -f', 'jython' ][ 'JYTHON_JAR' in dir( sys ) ] print 'Usage: %s %s.py' % ( which, __name__ ) sys.exit()
# Role: PropertyChangeListener event handler for progressTask instance #--------------------------------------------------------------------------- def propertyUpdate(self, event): if event.getPropertyName() == 'progress': progress = event.getNewValue() # integer % complete PB = self.progressBar PB.setIndeterminate(0) lo = PB.getMinimum() hi = PB.getMaximum() here = int((hi - lo) * 0.01 * progress) + lo # print '%3d%% of %3d..%3d = %3d' % ( progress, lo, hi, here ) PB.setValue(here) if progress == 100: self.button.setEnabled(1) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(ProgressBar()) if 'AdminConfig' in dir(): raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script should be executed, not imported.\n' which = ['wsadmin -f', 'jython']['JYTHON_JAR' in dir(sys)] print 'Usage: %s %s.py' % (which, __name__) sys.exit()
# -*- coding: utf-8 -*- from java.awt import EventQueue from java.lang import Runnable from gui.Gui import Gui class AwtRun(Runnable): def run(self): gui = Gui() gui.draw() if __name__ == '__main__': EventQueue.invokeLater(AwtRun())
locationRelativeTo=None, defaultCloseOperation=JFrame.EXIT_ON_CLOSE) text = '<html><font color="red">Off</font>' label = frame.add(JToggleButton(text, itemStateChanged=self.toggle)) frame.setVisible(1) #--------------------------------------------------------------------------- # Name: toggle() # Role: ItemListener event handler #--------------------------------------------------------------------------- def toggle(self, event): button = event.getItem() button.setText('<html><font color="%s">%s</font>' % [('red', 'Off'), ('green', 'On')][button.isSelected()]) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(HTMLtext_03()) if 'AdminConfig' in dir(): raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script should be executed, not imported.\n' which = ['wsadmin -f', 'jython']['JYTHON_JAR' in dir(sys)] print 'Usage: %s %s.py' % (which, __name__) sys.exit()
#--------------------------------------------------------------------------- def run(self): frame = JFrame('VerifierTest3', locationRelativeTo=None, defaultCloseOperation=JFrame.EXIT_ON_CLOSE) self.verifier = inputChecker() frame.add( JTextField('Enter "pass"', actionPerformed=self.verify, inputVerifier=self.verifier), BorderLayout.NORTH) frame.add(JTextField('TextField 2'), BorderLayout.SOUTH) frame.pack() frame.setVisible(1) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(VerifierTest3()) if 'AdminConfig' in dir(): raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script should be executed, not imported.\n' which = ['wsadmin -f', 'jython']['JYTHON_JAR' in dir(sys)] print 'Usage: %s %s.py' % (which, __name__) sys.exit()
#--------------------------------------------------------------------------- # Name: about() # Role: Event handler for "Help" -> "About" menu item #--------------------------------------------------------------------------- def about(self, event): print 'Menu4.about()' #--------------------------------------------------------------------------- # Name: exit() # Role: Event handler for "File" -> "Exit" menu item #--------------------------------------------------------------------------- def exit(self, event): print 'Menu4.exit()' sys.exit() #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(Menu4()) if 'AdminConfig' in dir(): raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script should be executed, not imported.\n' which = ['wsadmin -f', 'jython']['JYTHON_JAR' in dir(sys)] print 'Usage: %s %s.py' % (which, __name__) sys.exit()
actionPerformed = self.enter ) ) self.result = None dialog.pack() dialog.setVisible( 1 ) self.label.setText( 'Name = "%s"' % self.result ) #--------------------------------------------------------------------------- # Name: enter() # Role: ActionListener event handler - invoked when user presses <Enter> #--------------------------------------------------------------------------- def enter( self, event ) : self.result = self.text.getText() self.dialog.setVisible( 0 ) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in [ '__main__', 'main' ] : EventQueue.invokeLater( CustomDialog() ) if 'AdminConfig' in dir() : raw_input( '\nPress <Enter> to terminate the application:\n' ) else : print '\nError: This script should be executed, not imported.\n' which = [ 'wsadmin -f', 'jython' ][ 'JYTHON_JAR' in dir( sys ) ] print 'Usage: %s %s.py' % ( which, __name__ ) sys.exit()
#--------------------------------------------------------------------------- def insert(self, event): todo = event.getActionCommand() word = self.text.getText() print '%s: "%s"' % (todo, word) #--------------------------------------------------------------------------- # Name: selection() # Role: ListSelectionListener event handler #--------------------------------------------------------------------------- def selection(self, e): index = e.getSource().getSelectedIndex() if not e.getValueIsAdjusting(): print 'selected %d' % index #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(List5()) if 'AdminConfig' in dir(): raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script should be executed, not imported.\n' which = ['wsadmin -f', 'jython']['JYTHON_JAR' in dir(sys)] print 'Usage: %s %s.py' % (which, __name__) sys.exit()
# Role: Instantiate the user class # Note: Invoked by the Swing Event Dispatch Thread #--------------------------------------------------------------------------- def run(self): frame = JFrame('Tree5', size=(200, 200), defaultCloseOperation=JFrame.EXIT_ON_CLOSE) tree = self.cellTree() tree.getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION) frame.add(JScrollPane(tree)) frame.setVisible(1) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: if 'AdminConfig' in dir(): EventQueue.invokeLater(Tree5()) raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script requires a WebSphere environment.' print 'Usage: wsadmin -f Tree5.py' else: print '\nError: This script should be executed, not imported.\n' print 'Usage: wsadmin -f %s.py' % __name__ sys.exit()
c.ipady = 32 # make this one taller container.add( JButton( 'Four shalt thou not count' ), c ) c = GridBagConstraints() c.gridx = 1 # middle column c.gridy = 4 # put on a new row c.gridwidth = 3 # make this one 3 columns wide container.add( JButton( 'Five is right out' ), c ) #--------------------------------------------------------------------------- # Name: buttonPress() # Role: Event handler #--------------------------------------------------------------------------- def buttonPress( self, event ) : print event #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in [ '__main__', 'main' ] : EventQueue.invokeLater( GridBagLayout3() ) if 'AdminConfig' in dir() : raw_input( '\nPress <Enter> to terminate the application:\n' ) else : print '\nError: This script should be executed, not imported.\n' which = [ 'wsadmin -f', 'jython' ][ 'JYTHON_JAR' in dir( sys ) ] print 'Usage: %s %s.py' % ( which, __name__ ) sys.exit()
#------------------------------------------------------------------------------- class Button_01(java.lang.Runnable): #--------------------------------------------------------------------------- # Name: run() # Role: Instantiate the user class # Note: Invoked by the Swing Event Dispatch Thread #--------------------------------------------------------------------------- def run(self): frame = JFrame('Title') frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) frame.add(JButton('Press me')) frame.pack() frame.setVisible(1) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(Button_01()) if 'AdminConfig' in dir(): raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script should be executed, not imported.\n' which = ['wsadmin -f', 'jython']['JYTHON_JAR' in dir(sys)] print 'Usage: %s %s.py' % (which, __name__) sys.exit()
# Center the application frame in the window #----------------------------------------------------------------------- frame = self.frame = JFrame( 'WASports_00', bounds = ( x, y, w, h ), defaultCloseOperation = JFrame.EXIT_ON_CLOSE ) #----------------------------------------------------------------------- # Internal frames require us to use a JDesktopPane() #----------------------------------------------------------------------- desktop = JDesktopPane() frame.setContentPane( desktop ) frame.setVisible( 1 ) #------------------------------------------------------------------------------- # Role: main entry point - verify that the script was executed, not imported. #------------------------------------------------------------------------------- if __name__ == '__main__' : if 'AdminConfig' in dir() : EventQueue.invokeLater( WASports_00() ) raw_input( '\nPress <Enter> to terminate the application:\n' ) else : print '\nError: This script requires a WebSphere environment.' print 'Usage: wsadmin -f WASports_00.py' else : print '\nError: This script should be executed, not imported.\n' print 'Usage: wsadmin -f %s.py' % __name__ sys.exit()
# Note: This is a brute force implementation, just to demonstrate some ideas #--------------------------------------------------------------------------- def caretUpdate(self, event, regexp=None): if not regexp: regexp = re.compile('\W+', re.MULTILINE) pos = event.getDot() text = self.area.getText() if text.strip() == '': words = lines = 0 else: words = len(re.split(regexp, text)) lines = len(text.splitlines()) msg = '# words: %d # lines: %d' % (words, lines) self.words.setText(msg) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(SimpleEditor()) if 'AdminConfig' in dir(): raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script should be executed, not imported.\n' which = ['wsadmin -f', 'jython']['JYTHON_JAR' in dir(sys)] print 'Usage: %s %s.py' % (which, __name__) sys.exit()
class getHeaders5(java.lang.Runnable): #--------------------------------------------------------------------------- # Name: run() # Role: Instantiate the user class # Note: Invoked by the Swing Event Dispatch Thread #--------------------------------------------------------------------------- def run(self): frame = JFrame('JFrame headers', size=(600, 250), locationRelativeTo=None, defaultCloseOperation=JFrame.EXIT_ON_CLOSE) url = 'http://docs.oracle.com/javase/7/docs/api/javax/swing/JFrame.html' headerTask(url, frame).execute() frame.setVisible(1) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(getHeaders5()) if 'AdminConfig' in dir(): raw_input('\nPress <Enter> to terminate the application:\n') else: print '\nError: This script should be executed, not imported.\n' print 'Usage: %s %s.py' % (which, __name__) sys.exit()
def run(self): frame = JFrame('cbEdit2', size=(200, 112), locationRelativeTo=None, defaultCloseOperation=JFrame.EXIT_ON_CLOSE) table = JTable(tm()) table.setDefaultRenderer(JComboBox, cbRenderer()) table.setDefaultEditor(JComboBox, cbEditor()) frame.add(JScrollPane(table)) frame.setVisible(1) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in ['__main__', 'main']: EventQueue.invokeLater(cbEdit2()) if 'AdminConfig' in dir(): if sys.version.startswith('2.1'): msg = '\nPress <Enter> to terminate this application:\n' else: msg = '' raw_input(msg) else: print '\nError: This script should be executed, not imported.\n' which = ['wsadmin -f', 'jython']['JYTHON_JAR' in dir(sys)] print 'Usage: %s %s.py' % (which, __name__) sys.exit()
def g(): EventQueue.invokeAndWait(PyRunnable())
[ 'LINE_START', BorderLayout.LINE_START ], [ 'LINE_END' , BorderLayout.LINE_END ], ] for name, pos in data : frame.add( JButton( name ), pos ) big = JButton( 'CENTER', preferredSize = Dimension( 256, 128 ) ) frame.add( big, BorderLayout.CENTER ) frame.pack() frame.setVisible( 1 ) #------------------------------------------------------------------------------- # Name: anonymous # Role: Verify that the script was executed, and not imported and instantiate # the user application class on the Swing Event Dispatch Thread #------------------------------------------------------------------------------- if __name__ in [ '__main__', 'main' ] : EventQueue.invokeLater( BorderLayoutDemo() ) if 'AdminConfig' in dir() : raw_input( '\nPress <Enter> to terminate the application:\n' ) else : print '\nError: This script should be executed, not imported.\n' which = [ 'wsadmin -f', 'jython' ][ 'JYTHON_JAR' in dir( sys ) ] print 'Usage: %s %s.py' % ( which, __name__ ) sys.exit()