我想知道如果该窗口依赖于另一个窗口,那么是否不应该使用JDialogs而不是Jframes。
一种解决方案是使用类字段来保存对窗口(Jframe或JDialog)的引用,并检查其是否为null或可见,如果是,则延迟创建/打开窗口,
public void newChat(User user) { if (chatWindow == null) { // create chatWindow in a lazy fashion chatWindow = new JDialog(myMainframe, "Chat", ); // ... set up the chat window dialog } chatWindow.setVisible(true); addTabWithUser(user);}但是,根据提供的信息,我只能说这些。如果需要更多具体帮助,则需要提供更多信息。



