public void writeMessage(String from, String message) {
    Date date = new Date();
    StringBuilder builder = new StringBuilder();

    builder.append("<font color=");
    if (from.compareTo(USER) == 0) {
      builder.append("blue>");
    }
    else {
      builder.append("red>");
    }
    builder.append("(");
    builder.append(dateFormat.format(date));
    builder.append(") <b>");
    builder.append(from);
    builder.append("</b></font>: ");
    builder.append(message);
    builder.append("<br>");

    // write on UI in EDT
    EventQueue.invokeLater(new Runnable() {
      @Override
      public void run() {
        StyledDocument styleDoc = conversationDisplayArea.getStyledDocument();
        HTMLDocument doc = (HTMLDocument) styleDoc;
        Element last = doc.getParagraphElement(doc.getLength());
        try {
          doc.insertBeforeEnd(last, builder.toString());
        }
        catch (BadLocationException | IOException e) {
          // message display failed
        }
      }
    });
  }