Hello Kent,

Yes, it worked perfectly.
Hmm, seems that I have to read a bit more of Java... as I said, I am totally new with the topic.
Thank you all for your kind answers!.

Good Luck!


Juan



On 4/4/06, Kent Johnson <kent37@tds.net> wrote:
Juan Jose Costello Levien wrote:
> You mean that I have to instantiate Class1 instead of john?
> In that case, am I going to create the class modified with the
> overloaded method jButton2MouseClicked()?

No, you have to write your own main(). Class1.main() is a *static*
function, it creates an instance of Class1. The instance of john that
you create is not used for anything.

You could probably just do
john().setVisible(1)

Kent
>
> Juan
>
>
>
> On 4/4/06, *Jeff Emanuel* <jemanuel@frii.com <mailto: jemanuel@frii.com>>
> wrote:
>
>     In main, you create an instance of the superclass, not
>     your jython subclass.
>
>     Juan Jose Costello Levien wrote:
>      > Hello,
>      >
>      > I am trying to start a work with Java-NetBeans-Jython trío.
>      > 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 = "Hola pato"
>      >
>      >
>      > str = '',''
>      > cls = john()
>      > #cls = 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="collapsed" desc=" Generated Code
>      > ">
>      >     public void initComponents() {
>      >         jButton1 = new javax.swing.JButton();
>      >         jScrollPane1 = new javax.swing.JScrollPane();
>      >         jList1 = new javax.swing.JList ();
>      >         jButton2 = new javax.swing.JButton();
>      >         jScrollPane2 = new javax.swing.JScrollPane();
>      >         jTextPane1 = new javax.swing.JTextPane();
>      >         jLabel1 = new javax.swing.JLabel ();
>      >         jTextField1 = new javax.swing.JTextField();
>      >         jLabel2 = 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 = { "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 = 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
>      >
>
>




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users