calling method in gui

how do i call the method trysScored from class SuperMethods in the gui when the button is clicked.

i want it to be able to put the methods result into jtextarea1

package psuper14;

/**

*

* @author KAYB2

*/

publicclass Super14GUIextends javax.swing.JApplet{

/** Initializes the applet Super14GUI */

publicvoid init()

{

SuperMethods worker =new SuperMethods();

System.out.println(worker.Max(myTeam));

System.out.println(worker.trysScored(myTeam));

try{

java.awt.EventQueue.invokeAndWait(new Runnable(){

publicvoid run(){

initComponents();

}

});

}catch (Exception ex){

ex.printStackTrace();

}

}

/** This method is called from within the init() method 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 ">

privatevoid initComponents(){

jPanel1 =new javax.swing.JPanel();

jScrollPane1 =new javax.swing.JScrollPane();

jTextArea1 =new javax.swing.JTextArea();

jButton1 =new javax.swing.JButton();

jButton2 =new javax.swing.JButton();

jTextArea1.setColumns(20);

jTextArea1.setRows(5);

jScrollPane1.setViewportView(jTextArea1);

jButton1.setText("trys scored");

jButton1.addActionListener(new java.awt.event.ActionListener(){

publicvoid actionPerformed(java.awt.event.ActionEvent evt){

jButton1ActionPerformed(evt);

}

});

jButton2.setText("exit");

jButton2.addActionListener(new java.awt.event.ActionListener(){

publicvoid actionPerformed(java.awt.event.ActionEvent evt){

jButton2ActionPerformed(evt);

}

});

javax.swing.GroupLayout jPanel1Layout =new javax.swing.GroupLayout(jPanel1);

jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(29, 29, 29)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jButton2)

.addComponent(jButton1))

.addContainerGap(14, Short.MAX_VALUE))

);

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(40, 40, 40)

.addComponent(jButton1)))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 68, Short.MAX_VALUE)

.addComponent(jButton2)

.addGap(49, 49, 49))

);

javax.swing.GroupLayout layout =new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addContainerGap())

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addGap(19, 19, 19)

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(45, Short.MAX_VALUE))

);

}// </editor-fold>

privatevoid jButton2ActionPerformed(java.awt.event.ActionEvent evt){

System.exit(0);

}

privatevoid jButton1ActionPerformed(java.awt.event.ActionEvent evt){

jTextArea1.setText(worker.trysScored());

}

// Variables declaration - do not modify

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JPanel jPanel1;

private javax.swing.JScrollPane jScrollPane1;

private javax.swing.JTextArea jTextArea1;

// End of variables declaration

}

[6830 byte] By [confusedboya] at [2007-11-27 8:29:43]
# 1
Since you declare your SuperMethods object (worker) inside the init method, this is the only place it exists due to scope. Try making it an instance variable instead.
floundera at 2007-7-12 20:20:04 > top of Java-index,Java Essentials,New To Java...
# 2
Why doesn't it work as written currently? Do you get an error message? does it compile but nothing happens?
petes1234a at 2007-7-12 20:20:04 > top of Java-index,Java Essentials,New To Java...
# 3
you mean like this?it doesnt workSuperMethods worker = new SuperMethods();jTextArea1.setText(worker.trysScored(myTeam));
confusedboya at 2007-7-12 20:20:04 > top of Java-index,Java Essentials,New To Java...
# 4
> Since you declare your SuperMethods object (worker)> inside the init method, this is the only place it> exists due to scope. Try making it an instance> variable instead.ah, I didn't see that. Good point.
petes1234a at 2007-7-12 20:20:04 > top of Java-index,Java Essentials,New To Java...
# 5
> you mean like this?> it doesnt work"it doesn't work" doesn't tell us much. If you want useful help, give useful information.
petes1234a at 2007-7-12 20:20:04 > top of Java-index,Java Essentials,New To Java...
# 6
> you mean like this?>Do you know what an instance or member variable is? If not, review your course material.
floundera at 2007-7-12 20:20:04 > top of Java-index,Java Essentials,New To Java...