Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to integrate a JButton with an external JFrame

Status
Not open for further replies.

brinker

Programmer
May 31, 2001
48
CA
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
 
Hey, ur codes seems abit too complicated... I don't quite get what you are doing by declaring a new SelectParam object and if it is null, insert it into the JTextArea, which doesn't make any sense?

Shouldn't it be 'if (doit != null)' instead?

Hope this helps,
Leon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top