WIP bug fix 3

This commit is contained in:
GustavoHMDS committed 2026-09-29 01:20:48 -03:00
1 parent fa4ee046b1
commit 23559dcc06
5 files changed
+8 -5

No files matched your search

@@ -20,7 +20,6 @@ public class ChatController {
private final HashMap<TcpConnection, JMenuItem> chatMenus;
private final HashMap<TcpConnection, ChatWindow> chatWindows;
public ChatController(MainWindow mainWindow, ChatMenu chatMenu) {
this.mainWindow = mainWindow;
publicChatWindow = new PublicChatWindow(mainWindow);
@@ -28,7 +27,9 @@ public class ChatController {
chatMenus = new HashMap<>();
chatWindows = new HashMap<>();
chatMenu.newMenuItem(new JMenuItem("Show global chat"), publicChatWindow);
this.chatMenu = chatMenu;
this.chatMenu.newMenuItem(new JMenuItem("Show global chat"), publicChatWindow);
}
public void addChatWindow(TcpConnection tcpConnection) {
@@ -36,10 +37,8 @@ public class ChatController {
PrivateChatWindow newChat = new PrivateChatWindow(mainWindow, tcpConnection);
chatWindows.put(tcpConnection, newChat);
JMenuItem newMenuItem = new JMenuItem();
chatMenus.put(tcpConnection, newMenuItem);
newMenuItem.setText(tcpConnection.getAddress().toString());
chatMenu.newMenuItem(newMenuItem, newChat);
}
+5 -1
View File
@@ -8,6 +8,7 @@ import pitiupi.net.Message;
import pitiupi.net.tcp.TcpConnection;
import pitiupi.plugin.PrivateConnectionPlugin;
import javax.swing.*;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
@@ -57,9 +58,12 @@ public class TestChat implements PrivateConnectionPlugin{
chatController.receivePublic(testChatMessage);
}
@Override
public void receivePrivateConnection(TcpConnection tcpConnection) {
chatController.addChatWindow(tcpConnection);
SwingUtilities.invokeLater(() -> {
chatController.addChatWindow(tcpConnection);
});
}
@Override