Package client

Class ChatGUI

java.lang.Object
client.ChatGUI

public class ChatGUI extends Object
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 Details

    • ChatGUI

      public ChatGUI()
      Constructs a default ChatGUI with an empty border layout.
    • ChatGUI

      public ChatGUI(Chat chat)
      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

      public JPanel getMainPanel()
      Returns the main container of the GUI.
      Returns:
      The JPanel containing the entire chat interface.
    • buildUserListPanel

      public void buildUserListPanel(ArrayList<String> activeUsers, ArrayList<String> inChatUsers)
      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

      public ArrayList<JLabel> createMessagePanel(Message message)
      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

      public void addMessage(Message message)
      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.