Package client
Class ChatGUI
java.lang.Object
client.ChatGUI
Handles the graphical user interface for a chat session.
This class manages the display of chat messages (text and images)
and the list of users in a split-pane view.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMessage(Message message) Adds a new message to the display in real-time.voidbuildUserListPanel(ArrayList<String> activeUsers, ArrayList<String> inChatUsers) Updates the user list panel with the current active userscreateMessagePanel(Message message) Transforms a Message object into a list of JLabels for display.Returns the main container of the GUI.
-
Constructor Details
-
ChatGUI
public ChatGUI()Constructs a default ChatGUI with an empty border layout. -
ChatGUI
Constructs a ChatGUI populated with data from an existing Chat object. Initializes layouts, populates message history, and sets up the user list. * @param chat The Chat object containing message history and user data.
-
-
Method Details
-
getMainPanel
Returns the main container of the GUI.- Returns:
- The JPanel containing the entire chat interface.
-
buildUserListPanel
Updates the user list panel with the current active users- Parameters:
activeUsers- A list of usernames that are currently active/online.inChatUsers- A list of usernames that are currently in the chat room.
-
createMessagePanel
Transforms a Message object into a list of JLabels for display. Handles timestamp formatting, user identification, and image rendering.- Parameters:
message- The message data to be converted.- Returns:
- An ArrayList of JLabels (header, content, and spacer).
-
addMessage
Adds a new message to the display in real-time. This method updates the UI components and scrolls to the bottom automatically.- Parameters:
message- The Message object to be added to the panel.
-