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.

Recommended Answers

All 2 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.