It is difficult to explain my problem. I have 2 classes. 1 is called System and the other Phonebook. There is a button called phonebookButton on a frame which a have created in the System class. When you press the button, I create an Object of the Phonebook class(Phonebook phone = new Phonebook() ). I then disable the button(phonebookButton.setEnabled(false) so you can't press it again. Works perfectly. Thats the easy part.

When you press the button another frame opens up. I have a Window Listener on the frame. What i want to happen now is when you close the frame(click on the X in the corner of the frame) the button from the System frame must be enabled again.

I tried this when you close the Phonebook frame:
System sys = new System();

Any help would be appreciated

12 Years
Discussion Span
Last Post by jwenting

Imagine what you're doing there and you will know why it does not do what you think it should.

You create a new System object (poor naming choice btw) and call a method on that.
What you WANT to do is call that method on another System object, the one which is currently displayed on your screen and launched the popup in the first place.

The way to do that is to hand a reference to that object to the PhoneBook which then passes it on to its WindowListener.
Phonebook phonebook = new Phonebook(this);
and so on...
Then you can call the method on the System object that's actually the correct one.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.