def browse( c ): svnc = SVNConnector() center = swing.JPanel( java.awt.BorderLayout()) center.add( svnc) label = swing.JLabel( "Status:") center.add( label, java.awt.BorderLayout.SOUTH) d = swing.JDialog() d.title = "Browse A Repository" cp = d.getContentPane() cp.setLayout( java.awt.BorderLayout()) cp.add( center ) jb = swing.JButton( "Browse") def view( event ): url = svnc.getUrl() can_connect = svnc.canConnect() if can_connect: repository = getRepository( url) browseRepository( d, repository) else: label.setText( "Status: Cant Connect" ) jb.actionPerformed = view cp.add( jb, java.awt.BorderLayout.SOUTH) d.pack() g.app.gui.center_dialog( d ) d.visible = 1
def createGui( self ): self.jd = jd = swing.JDialog() self.jd.setName( "Leodialog" ) jd.setTitle( "Libraries" ) jdc = jd.getContentPane() self.libs = lib = swing.JList() self.libs.setName( "Autolist" ) lib.setVisibleRowCount( 5 ) view = swing.JScrollPane( lib ) jdc.add( view, awt.BorderLayout.NORTH ) create = swing.JButton( "Create" ) create.actionPerformed = self.create add = swing.JButton( "Add" ) add.actionPerformed = self.add move = swing.JButton( "Move" ) move.actionPerformed = self.move remove = swing.JButton( "Remove" ) remove.actionPerformed = self.remove _open = swing.JButton( "Open" ) _open.actionPerformed = self.open close = swing.JButton( "Close" ) close.actionPerformed = self.close topjp = swing.JPanel() topjp.setLayout( awt.GridLayout( 2, 1 ) ) jdc.add( topjp, awt.BorderLayout.SOUTH ) self.message = swing.JTextField() mp = swing.JPanel() gbl = awt.GridBagLayout() mp.setLayout( gbl ) gbc = awt.GridBagConstraints() gbc.weightx = 1.0 gbc.weighty = 1.0 gbc.fill = 1 gbl.setConstraints( self.message, gbc ) mp.add( self.message ) topjp.add( mp )# , awt.BorderLayout.NORTH ) jp = swing.JPanel() jp.setLayout( awt.GridLayout( 1, 6 ) ) jp.add( create ) jp.add( add ) jp.add( move ) jp.add( remove ) jp.add( _open ) jp.add( close ) topjp.add( jp )#, awt.BorderLayout.SOUTH )
def __init__(self, name, version, about): """# Create and run a modal dialog giving the name, version and description of a plugin. """ root = g.app.root self.top = top = swing.JDialog() #self.top = top = Tk.Toplevel(root) #g.app.gui.attachLeoIcon(self.top) #top.title("About " + name) top.title = "About " + name #top.resizable(0,0) # neither height or width is resizable. #frame = Tk.Frame(top) #frame.pack(side="top") frame = swing.JPanel() top.add(frame) #@ << Create the contents of the about box >> #@+node:EKR.20040517080555.21:<< Create the contents of the about box >> #Tk.Label(frame, text="Version " + version).pack() #Tk.Label(frame, text=about, borderwidth=10,justify="left").pack() l1 = swing.JLabel("Version " + version) frame.add(l1) l2 = swing.JLabel(about) frame.add(l2) #@nonl #@-node:EKR.20040517080555.21:<< Create the contents of the about box >> #@nl #@ << Create the close button >> #@+node:EKR.20040517080555.22:<< Create the close button >> #buttonbox = Tk.Frame(top, borderwidth=5) #buttonbox.pack(side="bottom") buttonbox = swing.JPanel() top.add(buttonbox, java.awt.BorderLayout.SOUTH) #self.button = Tk.Button(buttonbox, text="Close", command=top.destroy) #self.button.pack(side="bottom") self.button = swing.JButton("Close") self.button.actionPerformed = lambda event: top.dispose() buttonbox.add(self.button) #@nonl #@-node:EKR.20040517080555.22:<< Create the close button >> #@nl g.app.gui.center_dialog(top) # Do this after packing.
def getDialog(self): self.dialog = swing.JDialog() self.dialog.setName("Leodialog") self.dialog.setTitle(self.path) self.dialog.getContentPane().setOpaque(False) #pass b = swing.JButton("Close") self.dialog.add(b, awt.BorderLayout.SOUTH) b.actionPerformed = lambda *args: self.dialog.dispose() self.addList(self.dialog) self.dialog.pack() x, y = g.app.gui._calculateCenteredPosition(self.dialog) self.dialog.setLocation(x, y) self.dialog.visible = 1
def getMessage(): d = swing.JDialog() d.setTitle( "Message") cp = d.getContentPane() cp.setLayout( java.awt.BorderLayout()) jta = swing.JTextArea() jsp = swing.JScrollPane( jta ) jsp.setPreferredSize( java.awt.Dimension( 250, 250 ) ) cp.add( jsp ) buttonpanel = swing.JPanel() cp.add( buttonpanel, java.awt.BorderLayout.SOUTH) write = swing.JButton( "Write") buttonpanel.add( write) write.actionPerformed = lambda event: d.dispose() d.pack() g.app.gui.center_dialog( d ) d.setModal( 1 ) d.visible = 1 return jta.getText()
# Usage: C:\IBM\WebSphere\AppServer\bin\wsadmin -f 01_WFD.py # or # C:\jython2.5.3\bin\jython 01_WFD.py # History: # date who ver Comment # -------- --- --- ---------- # 14/10/20 rag 0.0 New #------------------------------------------------------------------------------- import javax.swing as swing w = swing.JWindow() w.setSize(200, 200) w.setLocation(200, 200) w.setVisible(1) f = swing.JFrame('JFrame') f.setSize(200, 200) f.setLocation(450, 200) f.setVisible(1) d = swing.JDialog() d.setSize(200, 200) d.setLocation(700, 200) d.setVisible(1) if 'AdminConfig' in dir(): #--------------------------------------------------------------------------- # If executed using wsadmin, pressing <Enter> will terminate the script # C:\IBM\WebSphere\AppServer\bin\wsadmin -f 01_WinFrame.py #--------------------------------------------------------------------------- raw_input('\nPress <Enter> to terminate the application:')
def createTopFrame(self): self.frame = self.top = swing.JDialog() g.app.gui.addLAFListener(self.frame) self.top.title = "Compare files and directories"
def createWidgets(self): self.dialog = swing.JDialog() self.dialog.setTitle("Spell Checker") cpane = self.dialog.getContentPane() blayout = swing.BoxLayout(cpane, swing.BoxLayout.Y_AXIS) cpane.setLayout(blayout) self.word = swing.JTextField() self.word.setEditable(False) cwborder = sborder.TitledBorder("Current Word:") self.word.setBorder(cwborder) cpane.add(self.word) self.possible = swing.JTextField() pborder = sborder.TitledBorder("Change To:") self.possible.setBorder(pborder) cpane.add(self.possible) center = swing.JPanel() blayout = swing.BoxLayout(center, swing.BoxLayout.X_AXIS) center.setLayout(blayout) self.jlist = swing.JList() self.jlist.setSelectionMode( swing.ListSelectionModel.SINGLE_SELECTION) self.jlist.setVisibleRowCount(5) class _listSelectionListener(sevent.ListSelectionListener): def __init__(self, jlist, possible): self.jlist = jlist self.possible = possible def valueChanged(self, event): self.possible.setText(str(self.jlist.getSelectedValue())) self.jlist.addListSelectionListener( _listSelectionListener(self.jlist, self.possible)) spane = swing.JScrollPane(self.jlist) spborder = sborder.TitledBorder("Suggestions") spane.setBorder(spborder) center.add(spane) bpanel = swing.JPanel() blayout = swing.BoxLayout(bpanel, swing.BoxLayout.Y_AXIS) bpanel.setLayout(blayout) center.add(bpanel) change = swing.JButton("Change") change.actionPerformed = self.change changeall = swing.JButton("Change All") changeall.actionPerformed = self.changeAll ignore = swing.JButton("Ignore All") ignore.actionPerformed = self.ignore add = swing.JButton("Add") add.actionPerformed = self.add bpanel.add(change) bpanel.add(changeall) bpanel.add(ignore) bpanel.add(add) cpane.add(center) self.next = swing.JButton("Next") self.next.actionPerformed = self.checkNextWord self.close = swing.JButton("Close") self.close.actionPerformed = lambda event: self.dialog.hide() jpanel = swing.JPanel() jpanel.add(self.next) jpanel.add(self.close) cpane.add(jpanel) self.dialog.pack()
def _getDialog(self, title): jdialog = swing.JDialog(self.c.frame.top, title, True) jdialog.getContentPane().setName("Leodialog") return jdialog
def runAskLeoIDDialog(self): """Create and run a dialog to get g.app.LeoID.""" message = ("leoID.txt not found\n\n" + "Please enter an id that identifies you uniquely.\n" + "Your cvs login name is a good choice.\n\n" + "Your id must contain only letters and numbers\n" + "and must be at least 3 characters in length.") dialog = swing.JDialog() dialog.title = "Create a Leo ID" dialog.modal = 1 cpane = dialog.getContentPane() jta = swing.JTextArea() jta.setText(message) jta.editable = 0 cpane.add(jta, awt.BorderLayout.NORTH) jtf = swing.JTextField() jp = swing.JPanel() jp.setBorder(sborder.TitledBorder("Your ID:")) gbl = awt.GridBagLayout() jp.setLayout(gbl) gbc = awt.GridBagConstraints() gbc.fill = 1 gbc.weightx = 1 gbc.weighty = 1 gbl.setConstraints(jtf, gbc) jp.add(jtf) cpane.add(jp, awt.BorderLayout.CENTER) class _OK(swing.AbstractAction): def __init__(self): swing.AbstractAction.__init__(self, "OK") def actionPerformed(self, ae): dialog.dispose() jb = swing.JButton(_OK()) jb.setEnabled(False) jpanel2 = swing.JPanel() jpanel2.add(jb) cpane.add(jpanel2, awt.BorderLayout.SOUTH) class _Enabler(sevent.DocumentListener): def __init__(self): pass def changedUpdate(self, de): pass def insertUpdate(self, de): l = de.getDocument().getLength() if l >= 3: jb.setEnabled(True) def removeUpdate(self, de): l = de.getDocument().getLength() if l < 3: jb.setEnabled(False) jtf.getDocument().addDocumentListener(_Enabler()) dialog.pack() w, h = self._calculateCenteredPosition(dialog) dialog.setLocation(w, h) dialog.setAlwaysOnTop(1) splash.toBack() dialog.visible = 1 g.app.leoID = jtf.getText() splash.toFront()
# Name: 03_WFD.py # From: Swing for Jython # By: Robert A. (Bob) Gibson [rag] # ISBN-13: 978-1-4824-0818-2 (paperback) # ISBN-13: 978-1-4824-0817-5 (electronic) # website: http://www.apress.com/978148420818 # Role: Construct & displaying a JWindow, a JFrame & a JDialog only using # constructor keyword arguments. This technique takes advantage of # Jython idioms. # Note: Using Jython it is best to close the command prompt to exit # Usage: C:\IBM\WebSphere\AppServer\bin\wsadmin -f 03_WFD.py # or # C:\jython2.5.3\bin\jython 03_WFD.py # History: # date who ver Comment # -------- --- --- ---------- # 14/10/20 rag 0.0 New #------------------------------------------------------------------------------- import javax.swing as swing w = swing.JWindow( bounds = ( 200, 200, 200, 200 ), visible = 1 ) f = swing.JFrame( 'JFrame', bounds = ( 450, 200, 200, 200 ), visible = 1 ) d = swing.JDialog( bounds = ( 700, 200, 200, 200 ), visible = 1 ) if 'AdminConfig' in dir() : #--------------------------------------------------------------------------- # If executed using wsadmin, pressing <Enter> will terminate the script # C:\IBM\WebSphere\AppServer\bin\wsadmin -f 03_WFD.py #--------------------------------------------------------------------------- raw_input( '\nPress <Enter> to terminate the application:' )
def visualiseUndoStack(self): umanager = self.umanager table = swing.JTable(self.UneditableTableModel( )) #( data, util.Vector( [ 'spot', 'data', 'action', 'redo/undo' ] ) ) table.setSelectionMode(swing.ListSelectionModel.SINGLE_SELECTION) self.setDataForTable(table) jd = swing.JDialog() jd.setTitle("Undo Stack") cp = jd.getContentPane() cp.add(swing.JScrollPane(table)) bholder = swing.JPanel() cp.add(bholder, java.awt.BorderLayout.SOUTH) uto = swing.JButton("Undo To") bholder.add(uto) #@ <<_undoTo>> #@+node:zorcanda!.20050906183758:<<_undoTo>> def _undoTo(event): sr = table.getSelectedRow() if sr == -1: swing.JOptionPane.showMessageDialog( None, "No Selected Row", "Select A Row Please", swing.JOptionPane.INFORMATION_MESSAGE) return edits = umanager.getEdits() undo = edits.get(sr) if not undo.canUndo(): swing.JOptionPane.showMessageDialog( None, "Cant Undo To This Point", "Illegal Undo Selection", swing.JOptionPane.WARNING_MESSAGE) return self.ignore = 1 umanager.undoTo(undo) self.ignore = 0 self.setDataForTable(table) #@-node:zorcanda!.20050906183758:<<_undoTo>> #@nl uto.actionPerformed = _undoTo rto = swing.JButton("Redo To") bholder.add(rto) #@ <<_redoTo>> #@+node:zorcanda!.20050906183938:<<_redoTo>> def _redoTo(event): sr = table.getSelectedRow() if sr == -1: swing.JOptionPane.showMessageDialog( None, "No Selected Row", "Select A Row Please", swing.JOptionPane.INFORMATION_MESSAGE) return edits = umanager.getEdits() undo = edits.get(sr) if not undo.canRedo(): swing.JOptionPane.showMessageDialog( None, "Cant Redo To This Point", "Illegal Redo Selection", swing.JOptionPane.WARNING_MESSAGE) return self.ignore = 1 umanager.redoTo(undo) self.ignore = 0 self.setDataForTable(table) #@-node:zorcanda!.20050906183938:<<_redoTo>> #@nl rto.actionPerformed = _redoTo jb = swing.JButton("Close") jb.actionPerformed = lambda event: jd.dispose() bholder.add(jb) jd.pack() g.app.gui.center_dialog(jd) jd.setModal(1) jd.show()
def DebugWindow(): msg = swing.JDialog() msg.show()