Re: How do I pass a Text field value from one jFrame1 to jFrame2
- From: "Jeff" <jeffrey.summers@xxxxxxxxx>
- Date: 28 Nov 2006 03:25:38 -0800
dewan.islam@xxxxxxxxx wrote:
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!
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
.
- References:
- How do I pass a Text field value from one jFrame1 to jFrame2
- From: dewan . islam
- How do I pass a Text field value from one jFrame1 to jFrame2
- Prev by Date: migrate these new US DST settings from JRE1.4.2_11 into JRE 1.4.2_09
- Next by Date: Re: NEED YOUR HELP
- Previous by thread: How do I pass a Text field value from one jFrame1 to jFrame2
- Next by thread: migrate these new US DST settings from JRE1.4.2_11 into JRE 1.4.2_09
- Index(es):