Results 1 to 3 of 3
Thread: Obtein informaticon from other
- 08-23-2010, 08:29 PM #1
Member
- Join Date
- Aug 2010
- Posts
- 6
- Rep Power
- 0
Obtein informaticon from other
Hello! I have a doubt with the next:
I have a JFrame called Pablo and other called Pepe;
Both Jframe have a attribute String text;
I have a method:
Thanks! :)Java Code:public method(JFrame j){ //I need to do it sssomething with the variable text, like: j.text = "hola" //But i don't know which JFrame is!!! How Can I do to know what is it? }
- 08-23-2010, 09:52 PM #2
Member
- Join Date
- Jul 2010
- Posts
- 21
- Rep Power
- 0
Im not quite sure what you are saying. If you want the method to be specific to each frame, you could do this:
public method(JFrame j, String l)
{
j.text = l;
}
and call it like this: method(Pablo, "text");
Alternatively, you may be confusing the use of an argument. When you call a method, you would call it like this : method(Pablo);
that Pablo is then passed to j. j is now sort of a nickname for pablo. So now you would say j.text = "hola";
-
I would tend to go more towards an OOP solution where the code holding the JTextField in question has a public method called setMyText(String text), and sets the JTextField's text from within this method.


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks