Maulik
Maulik

Reputation: 1

Calling the same instance of JFrame from different JFrames

How do I call the same instance of a JFrame say A from 5 different JFrames if I need the display of A to be updated every time I call it??

Upvotes: 0

Views: 349

Answers (1)

Andrew Thompson
Andrew Thompson

Reputation: 168825

One way is to provide a reference to the frame to each of the 'child processes' and a public method that will update the UI.

Or since it is better not to extend JFrame, a utility class that has a reference to the JFrame and provides the public method.


BTW: Most apps. would have only a single JFrame. The way to handle the situation you describe might be better implemented using JDialogs or JOptionPanes for the 'secondary' windows. Or to collect all the GUI elements together into the main frame: JDesktopPane/JInternalFrames, CardLayout, JTabbedPane..

Upvotes: 1

Related Questions