Inside an event handler I want to send text to a seperate object. If I create the object inside the handler it works, but if the object is created by a different class it doesn't, even though the other class is public. How do I connect the method inside the handler to the object outside?
So I want to do this and it doesn't work,
But this works,
Thanks guys, this is tough at first but I'm slowly getting it.
posted 11 years ago
Where in your source is the declaration for innerclass? As long as it is within the mainProgram, you need to make an instance variable out of the textHolder, and addActionListener(new innerclass()); should be enough.
Of course, you need to connect it all to some gui. The textHolder will probably be an element of the gui, so make it an instance field there, and innerclass should also be contained in the main gui class (if you insist on using an inner class).