开发者

Calling the same instance of JFrame from different JFrames

How do I call the same instan开发者_JS百科ce of a JFrame say A from 5 different JFrames if I need the display of A to be updated every time I call it??


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..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜