All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.yaoqiang.collaboration.ChatTranscriptArea Maven / Gradle / Ivy

There is a newer version: 2.2.18
Show newest version
package org.yaoqiang.collaboration;

import java.awt.Color;
import java.util.Date;

import javax.swing.text.StyleConstants;

import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.util.StringUtils;
import org.yaoqiang.util.Constants;

/**
 * ChatTranscriptArea
 * 
 * @author Shi Yaoqiang([email protected])
 */
public class ChatTranscriptArea extends ChatArea {

	private static final long serialVersionUID = 1439838915718762613L;

	public ChatTranscriptArea() {
		setEditable(false);
	}

	public void insertMessage(Message message) {
		StyleConstants.setBold(styles, true);
		String from = message.getFrom();
		if (from == null) {
			from = MainPanel.getConnection().getUser();
			StyleConstants.setForeground(styles, new Color(32, 96, 0));
		} else {
			StyleConstants.setForeground(styles, new Color(64, 64, 255));
		}

		insertText(StringUtils.parseBareAddress(from) + " " + Constants.DF.format(new Date()) + "\n");
		StyleConstants.setBold(styles, false);
		StyleConstants.setForeground(styles, Color.DARK_GRAY);
		insertText(message.getBody() + "\n");
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy