2uzhan.com
Advertisement
Now Place:2uzhan.com » Copying textfield content from different class

Copying textfield content from different class

Software Development @ February 9, 2011   Views:0

Hi, guys. I am all new to java. Wondered if someone could help me please.

Basically what I am trying to achieve is:
when the button is pressed then content of textfield1 in class1 is copied to textfield2 in class2.
I would know how to do this in vb but totally blanked at java :/
Thanks for all answers :D

--------------Solutions-------------

Do you mean something like putting a getTextFromTextField1() method in class1, which class2 would call? That's probably what I would do.

Do you mean something like putting a getTextFromTextField1() method in class1, which class2 would call? That's probably what I would do.

Yes something like that. But not sure what code i should write within the getTextFromTextField1() method?

Well, a textfield will return its contents as a String, if you ask it nicely. Why not just make your getTextFromTextField1() a wrapper for that?

To add to what jon.kiparsky said, you will then need to create an instance of the class that contains the method you require:

FirstClass first = new FirstClass();

inside the class you want to use it in, then call that method using the Class.getTextFromTextField1() syntax, where Class is the name of the class containing that method.

first.getTextFromTextField1();

Before I get into the specific issues, I want to provide some other details:

  • Normally, I work on a live, paid server (even in dev); I realize that is ...

Yes, WPF. The learning curve is steep, but what amazing things you can do with it!
Look at this hexagon window for instance. Serves no purpose in a business environment ...

Hey there,

I am trying to create a register code. So basicly im making a quiz and every time a user starts up my program he/she needs to register (making ...

Tags:java
© 2018 2uzhan.com Contact