//find the related user chat window
CustomChatWindow chatWindow = contactHash.get(p.getUsername());
//add the message to it
chatWindow.addMessage(p);
//show the window if invisible
if (!chatWindow.isVisible()) {
chatWindow.setVisible(true);
chatWindow.setTitle("new message from " + p.getUsername());