I wonder if JDialogs should be used instead of JFrames if the window depends on another window.
The solution is to use the class field to bind to the window (JFrame or JDialog) and check if it is null or visible, and if so, lazily create / open the window,
public void newChat(User user) { if (chatWindow == null) {
but thatโs all I can say based on the information provided. If you need more specific help, you need to provide more information.
source share