I have been trying to solve this for the past 4 hours, so any pointers
would be helpful.
Problem: I have jTextField1 in jFrame1. When I call jFrame2 from
jFrame1 using "new jFrame2().setVisible(true);" command, I need to
retain the String value of jFrame1.jTextField1 in jFrame 2.
I tried creating a class called 'Global', and a public String variable
'a' within it.
1. I set Global.a = jTextField1.getText() from within jFrame1
2. jFrame2 is able to read and print the value of Global.a properly.
But, when I try this function, it it's getting caught in the if
statement - if (Global.a == "abc") {... }
What are my options for passing jFrame1.jTextField1 value to jFrame2,
so I can display that in the new form.
Thanks in advance!
Jeff - 28 Nov 2006 11:25 GMT
> I have been trying to solve this for the past 4 hours, so any pointers
> would be helpful.
[quoted text clipped - 14 lines]
>
> Thanks in advance!
In the class def for jFrame2, declare your variable and create a
function:
private String theString;
public void getMyString(String mystring) {
theString = mystring;
}
In the method where you declare jFrame2 to be visible, one line before
that use
jFrame2.getMyString(jTextField1.getText());
hth
/js