aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How do you get the text field value from another java file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How do you get the text field value from another java file" Watch "How do you get the text field value from another java file" New topic
Author

How do you get the text field value from another java file

bobby, morkos
Ranch Hand

Joined: Jan 04, 2002
Posts: 82
I have a Demo.java which contains a text field value and I want to get it from ProcessListeener.java. Could anyone help?
Michael Szul
Ranch Hand

Joined: Sep 18, 2001
Posts: 57
You would just have to pass the value to the other program:
public class Demo {
String value = "";
Listener.getThisText(value);
}
public class Listener {
public void getThisText(String value) {
}
}
Is something like this what you are referring to? You post wasn't very specific.
This is just one of several ways that you can pass information back and forth between classes.
bobby, morkos
Ranch Hand

Joined: Jan 04, 2002
Posts: 82
I cant because I have a class Listener. Is there a way, without writing to a file or xml and then retrieving it later.
class JTableButtonMouseListener implements MouseListener {
}
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Bobby,
All Events have a source associated with them, so just use it. For example, the following code listens to a textfield action event:

If you need some other object then the one sent then you will need to write accessors from the creating class and then call them from your listener class. You will also need to pass in a reference to the creating class (usually done through the constructor). For example:
tf.addActionListener( new Listener( this ) );
Regards,
Manfred.
bobby, morkos
Ranch Hand

Joined: Jan 04, 2002
Posts: 82
What if the text value changes all the time. Is there a way to listeen for a modification in the text field and change it accordingly. Thanks for your help.

Originally posted by Manfred Leonhardt:
Hi Bobby,
All Events have a source associated with them, so just use it. For example, the following code listens to a textfield action event:

If you need some other object then the one sent then you will need to write accessors from the creating class and then call them from your listener class. You will also need to pass in a reference to the creating class (usually done through the constructor). For example:
tf.addActionListener( new Listener( this ) );
Regards,
Manfred.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do you get the text field value from another java file