Hello all,
my problem is probably a fairly routine one. I have built an application which consists of 2 classes. The first class is the main class and contains a word processor like text area and a menu bar. The second class contains a JFrame including various text JTextFields and one JButton.
When the JButton is clicked, some calcuculations occur in the second class and a string is output (method toString() in second class). I would appreciate it if anybody could give me any information regarding how I can insert this output string into the JText area of the first class automatically when the JButton from the second class is clicked. The string output is dependent on the variables input into the JTextFields. I know how to insert the string statically into the text area, but this result is wrpng as the program does not realize that the values in the JTextFields have changed ,and only uses the initial values. This is what I am doing:
class1
new ActionListener() {
public void actionPerformed(ActionEvent e)
{
SelectParam doit = new SelectParam();
if (doit==null)
{
t1.insert(doit.toString(),0); //problem with code here.
}
}
}
);
----------------------------------------------------------
class 2
private String doneButtonActionPerformed(java.awt.event.ActionEvent evt) {
// this method should read in the values of the frame and then pass them
// to the local class variables.
currRank=new String(myRank.getText()); //my rank variable
proc=new String(procText.getText()); //#processors variable
communicator=new String(globalComm.getText()); //communicator variable
tag=Integer.parseInt(msgTag.getText()); //default msg tag
statusName=new String(recvVar.getText()); //default status tag
return toString();
}
thanks
my problem is probably a fairly routine one. I have built an application which consists of 2 classes. The first class is the main class and contains a word processor like text area and a menu bar. The second class contains a JFrame including various text JTextFields and one JButton.
When the JButton is clicked, some calcuculations occur in the second class and a string is output (method toString() in second class). I would appreciate it if anybody could give me any information regarding how I can insert this output string into the JText area of the first class automatically when the JButton from the second class is clicked. The string output is dependent on the variables input into the JTextFields. I know how to insert the string statically into the text area, but this result is wrpng as the program does not realize that the values in the JTextFields have changed ,and only uses the initial values. This is what I am doing:
class1
new ActionListener() {
public void actionPerformed(ActionEvent e)
{
SelectParam doit = new SelectParam();
if (doit==null)
{
t1.insert(doit.toString(),0); //problem with code here.
}
}
}
);
----------------------------------------------------------
class 2
private String doneButtonActionPerformed(java.awt.event.ActionEvent evt) {
// this method should read in the values of the frame and then pass them
// to the local class variables.
currRank=new String(myRank.getText()); //my rank variable
proc=new String(procText.getText()); //#processors variable
communicator=new String(globalComm.getText()); //communicator variable
tag=Integer.parseInt(msgTag.getText()); //default msg tag
statusName=new String(recvVar.getText()); //default status tag
return toString();
}
thanks