This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
Use static field in another class
Posted by Kishori Sharan on April 03, 2001 at 4:03 PM
Here is what I understand from your posting: You have a textfield where user will enter some text. This text should be available inside another class. Let the another class name be C2. Create a static string field in class C2 and then set that field value reading text from textfiled. class C2 { private static String text ; public setText ( String text ) { this.text = text ; } } // This is the class where you read from textfield class C1 { // Read text from text field String text = ...; //Set this text in C2 class C2.setText ( text ) ; } This way your textfield text is stored in C2 and you can use it whenever you want.
Replies:
|