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
posted
0
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 { }
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
posted
0
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.