From: Juan J. C. L. <jcl...@gm...> - 2006-04-04 19:34:10
|
Hi Fred, You mean that I can generate Jython code from the Netbeans GUI editor directly? Awesome! I am going to have a look at the jython page (www.jython.org) and see what you said. Juan On 4/4/06, Sells, Fred <fr...@ad...> wrote: > > not to ignore your question, but... I find swing GUI much easier in > jython > than java. look at eventhandlers in the jython component constructors > > -----Original Message----- > From: jyt...@li... > [mailto:jyt...@li...]On Behalf Of Juan Jose > Costello Levien > Sent: Tuesday, April 04, 2006 7:18 AM > To: jyt...@li... > Subject: [Jython-users] Some questions about Jython and Java with > Netbeans [html-removed] > Importance: Low > > > Hello, > > I am trying to start a work with Java-NetBeans-Jython tr=EDo. > This is my first work with them, that's why I post a message to this list > (don't be cruel with me, hehe... :-) > > Well, the problem is the following: > > I have created a Java Application project inside NetBeans. > Inside it, there is a Java Class, Class1, which simply implements a GUI I > made for the project. The idea is to write all the hard work in Jython, > and > only the GUI has to be made with Java. > > What I thought is to overload event methods of the Java Class with Jython > to > fire Jython code when I press a button of the GUI. > But when I do it, it simply ignores my Jython code. Here I post them for > your convenience: > > # Jython source file > import javaapplication1 > > class john(javaapplication1.Class1): > def jButton2MouseClicked(self, evt): > jButton2.label =3D "Hola pato" > > > str =3D '','' > cls =3D john() > #cls =3D Pancho() > cls.main(str) > print "Finished." > > > //Java Class > > > package javaapplication1; > > > public class Class1 extends javax.swing.JFrame { > > /** Creates new form NewJFrame */ > public Class1() { > initComponents(); > } > > /** This method is called from within the constructor to > * initialize the form. > * WARNING: Do NOT modify this code. The content of this method is > * always regenerated by the Form Editor. > */ > // <editor-fold defaultstate=3D"collapsed" desc=3D" Generated Code > "> > public void initComponents() { > jButton1 =3D new javax.swing.JButton(); > jScrollPane1 =3D new javax.swing.JScrollPane(); > jList1 =3D new javax.swing.JList(); > jButton2 =3D new javax.swing.JButton(); > jScrollPane2 =3D new javax.swing.JScrollPane(); > jTextPane1 =3D new javax.swing.JTextPane(); > jLabel1 =3D new javax.swing.JLabel(); > jTextField1 =3D new javax.swing.JTextField(); > jLabel2 =3D new javax.swing.JLabel(); > > setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE > ); > jButton1.setText("Desconectar cliente"); > jButton1.addMouseListener(new java.awt.event.MouseAdapter() { > public void mouseClicked(java.awt.event.MouseEvent evt) { > jButton1MouseClicked(evt); > } > }); > > jList1.setFont(new java.awt.Font("Dialog", 0, 10)); > jList1.setModel(new javax.swing.AbstractListModel() { > String[] strings =3D { "Item 1", "Item 2", "Item 3", "Item 4", > "Item 5" }; > public int getSize() { return strings.length; } > public Object getElementAt(int i) { return strings[i]; } > }); > jScrollPane1.setViewportView(jList1); > > jButton2.setText("Control Remoto"); > jButton2.addMouseListener(new java.awt.event.MouseAdapter() { > public void mouseClicked(java.awt.event.MouseEvent evt) { > jButton2MouseClicked(evt); > } > }); > > jTextPane1.setBackground(new java.awt.Color(0, 0, 0)); > jTextPane1.setForeground(new java.awt.Color(255, 255, 255)); > jScrollPane2.setViewportView(jTextPane1); > > jLabel1.setText("Comando>"); > > jLabel2.setFont(new java.awt.Font("Dialog", 0, 10)); > jLabel2.setText("Esta consola fue realizada por Juan Jose Costello > Levien. Todos los derechos reservados."); > > org.jdesktop.layout.GroupLayout layout =3D new > org.jdesktop.layout.GroupLayout(getContentPane()); > getContentPane().setLayout(layout); > layout.setHorizontalGroup( > layout.createParallelGroup( > org.jdesktop.layout.GroupLayout.LEADING) > .add(layout.createSequentialGroup() > .addContainerGap() > .add(layout.createParallelGroup( > org.jdesktop.layout.GroupLayout.LEADING) > .add(jScrollPane2, > org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 586, Short.MAX_VALUE) > .add(layout.createSequentialGroup() > .add(jScrollPane1, > org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 425, > org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) > .addPreferredGap( > org.jdesktop.layout.LayoutStyle.RELATED) > .add(layout.createParallelGroup( > org.jdesktop.layout.GroupLayout.LEADING, false) > .add(jButton2, > org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, > org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) > .add(jButton1, > org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, > org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) > .add(layout.createSequentialGroup() > .add(jLabel1) > .addPreferredGap( > org.jdesktop.layout.LayoutStyle.RELATED) > .add(jTextField1, > org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 504, Short.MAX_VALUE)) > .add(jLabel2)) > .addContainerGap()) > ); > layout.setVerticalGroup( > layout.createParallelGroup( > org.jdesktop.layout.GroupLayout.LEADING) > .add(layout.createSequentialGroup() > .addContainerGap() > .add(layout.createParallelGroup( > org.jdesktop.layout.GroupLayout.LEADING) > .add(layout.createSequentialGroup() > .add(jButton1) > .add(15, 15, 15) > .add(jButton2, > org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)) > .add(jScrollPane1, > org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 115, > org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) > .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) > .add(jScrollPane2, > org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 233, > org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) > .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) > .add(layout.createParallelGroup( > org.jdesktop.layout.GroupLayout.BASELINE) > .add(jLabel1) > .add(jTextField1, > org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, > org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, > org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) > .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, > 16, Short.MAX_VALUE) > .add(jLabel2) > .addContainerGap()) > ); > pack(); > }// </editor-fold> > > public void jButton2MouseClicked(java.awt.event.MouseEvent evt) > { > // TODO add your handling code here: > //jList1.list(); > > > > } > > public void jButton1MouseClicked(java.awt.event.MouseEvent evt) > { > // TODO add your handling code here: > > > } > > /** > * @param args the command line arguments > */ > public static void main(String args[]) { > java.awt.EventQueue.invokeLater(new Runnable() { > public void run() { > new Class1().setVisible(true); > } > }); > } > > // Variables declaration - do not modify > public javax.swing.JButton jButton1; > public javax.swing.JButton jButton2; > public javax.swing.JLabel jLabel1; > public javax.swing.JLabel jLabel2; > public javax.swing.JList jList1; > public javax.swing.JScrollPane jScrollPane1; > public javax.swing.JScrollPane jScrollPane2; > public javax.swing.JTextField jTextField1; > public javax.swing.JTextPane jTextPane1; > // End of variables declaration > > } > > > > Hope you can give me some light. > Thanks. > > > Juan > > > -------------------------------------------------------------------------= -- > The information contained in this message may be privileged and / or > confidential and protected from disclosure. If the reader of this message > is > not the intended recipient, you are hereby notified that any > dissemination, > distribution or copying of this communication is strictly prohibited. If > you > have received this communication in error, please notify the sender > immediately by replying to this message and deleting the material from an= y > computer. > > -------------------------------------------------------------------------= -- > |