Hi all,

I've got a main form, and a secondary form (this being a list from which I pick a number).

I can store values as "global" variables - so as to bring the value across different classes. Also I've managed to get the main JFrame to display the value selected in a textfield... via a "calculate" button.

Problem: I want the textfield in the main JFrame to update itself when I close the secondary JFrame... (and not have to have a separate "calculate" button as I'm doing now).

Can anyone help?

Much, much appreciated,
a java (very) newbie.

Then you will need a WindowListener on the secondary JFrame. In particular, you will need to declare your secondary JFrame's class as "implements WindowListener" and then you will need to implement each of the methods found here. Look at the windowClosed() method in particular; since it gets called when your window is closed, you should be able to get the text from your secondary JFrame, then update the other JFrame's text field using its setText() method.

Hope that helps. Let me know if you have any questions.

This question has already been answered. Start a new discussion instead.