updating the value in frame1 if changed in frame2

hi,

i have two frames....frame 1 has button calculate....frame 2 has button update which can update the data on frame two.....so the scene can be like that user might or might not want to update data on form 2 but in either case will calculate.....The approach that i was thinking of is that if i update it i store it in a JtextField2 on frame2 ...read the value in frame1 and compare with the value when updated wasnt hit....if values are same the result can be the standard value else it will store the value from JtextField.....now i have a question....

1) is this approach fine?.....How can i tell calculate that Update was hit or not?...is there any way by which i can get that a button in frame2 was hit or not?

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

table1 t1 =new table1();//frame 2

String a1 = t1.jTextField1.getText();//frame2....reads the data from textfield 1

String a4 = jTextField1.getText();//frame1

double anum1, anum4;

anum1 = Double.parseDouble(a1);

anum4 = Double.parseDouble(a4);

double asum = anum1*anum4 ;

System.out.println("i am NOT UPDATED value--> "+asum );

String tabsum = t1.jTextField2.getText();//text field2 has the updated value of the product with which asum will be compared

double tsum1 = Double.parseDouble(tabsum);

System.out.println("i am UPDATED value--> "+tsum1);

for some reason it is not reading the content of jTextField2 of frame2 and showing the error -> Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "jTextField2"

Thanks

[2060 byte] By [ElishaWa] at [2007-11-27 9:55:41]
# 1
please help ppl...please tell me how can i make sure that frame 1 knows everytime a button in frame 2 is hit.....i have this assignment due in 6 hrs
ElishaWa at 2007-7-13 0:25:42 > top of Java-index,Desktop,Core GUI APIs...
# 2
> please help ppl...You got help the last time you asked a question. You never bother to reply to the posting or follow the advice given, so I would just be wasting my time trying to help again.
camickra at 2007-7-13 0:25:42 > top of Java-index,Desktop,Core GUI APIs...
# 3

Hey camickr

seriously your advice is always of great help. I really appreciate all your help and i can get things running after i follow your advice but since am using NETBEANS making SSCCE takes me even longer thats why i was trying to do it myself.....

Sorry for not replying!! :(

ElishaWa at 2007-7-13 0:25:42 > top of Java-index,Desktop,Core GUI APIs...
# 4

> or find a workaround?

> but since am using NETBEANS making SSCCE takes me even longer thats why i was trying to do it myself

Then don't use Netbeans.

The point is to make a simple example that you understand. Once you get the simple example working you incorporate the knowledge you learned into your main program.

It makes no difference if a component is defined on a second frame or the same frame. As long as you have the correct reference you can update it from any frame.

We can't help you with your currently stated question, because the problem is probably contained outside the posted code. As I told you earlier, the problem is likely that you have an incorrect reference to one of your components. Since we can't see where you declared each variable we can't help you.

camickra at 2007-7-13 0:25:42 > top of Java-index,Desktop,Core GUI APIs...
# 5

hi

I could fix the last problem but now i am stuck with amother problem.....can any one please suggest changes......

t1 is another frame that has been initialised and has been made public and that frame has a string value str1.....i wanted to ask the code for reading a string variable from another frame....is this the right way?

String a1 = t1.str1;

ElishaWa at 2007-7-13 0:25:42 > top of Java-index,Desktop,Core GUI APIs...
# 6

> is this the right way?

Not really. You should never access a variable directly. Generally you would create a method that returns the value of the variable you want. For example in the frame you create a method, getName(); Then you use frame.getName().

Thats why the API is full of get... and set... methods.

camickra at 2007-7-13 0:25:42 > top of Java-index,Desktop,Core GUI APIs...
# 7
all right...i will try thatThanks
ElishaWa at 2007-7-13 0:25:42 > top of Java-index,Desktop,Core GUI APIs...