I am still having difficulty properly routing text messages when multiples users chat with one other person. I have a constructor that creates a new JFrame every time it’'s called, therefore creating a popup window and displaying the text received. Is it possible to create new objects (each object representing the chat window via JFrame) and it into a HashMap? I want to then retrieve the correct object via an index value which would be the user name sending the chat, and have the text be displayed in that JFrame.
I implemented it, but it’‘s not working. i don’'t know how to retrieve the object, and call JTextArea on it. Anyone work with this before? Perhaps give me an example that would work?
In case you’‘re wondering, this is what’'s currently happening:
Let’‘s say we have User2, and User3 who want to chat with User1. User2 and User3 send an initial message and it’‘s successfuly received, new chat windows are popped up. But now, whenever User2 or User3 type a message and send it to User1, it appears in User3’'s window! So messages are always received in the most recent chat object.
I’‘ve been struggling with this for some time, and haven’'t found a solution, so please help!