String title = tabbedPane.getTitleAt(index);
String color = Utils.colorToHex(((MenuToggleButton) colorTB).getColor());
msg = "<p style=\"color:" + color + ";\">" + msg + "</p>";
if (title.equals("Principale")) {
try {
user.broadcastMessage(new Message(msg, username, data, Message.PUBLIC_MASSAGE));
((ChatArea) chatArea).append(new Message(msg, username, data, Message.PUBLIC_MASSAGE));
} catch (RemoteException ex) {
((ChatArea) chatArea).append(new Message(msg, username, data, Message.WARNING_MESSAGE));
}
} else {
String receiver = "";
Hashtable<String, MobileServer> list = user.getPrivateList();
Enumeration<String> it = list.keys();
while (!receiver.equals(title) && it.hasMoreElements()) {
receiver = it.nextElement();
}
if (receiver.equals(title)) {
try {
list.get(receiver).sendMessage(new Message(msg, username, data, Message.PRIVATE_MASSAGE));
getPrivateArea(receiver).append(new Message(msg, username, data, Message.PRIVATE_MASSAGE));
} catch (RemoteException ex) {
((ChatArea) chatArea).append(new Message(msg, username, data, Message.WARNING_MESSAGE));
}
} else {
JOptionPane.showMessageDialog(this, "Non esiste la referenza per " + title, "Private chat", JOptionPane.WARNING_MESSAGE);
}
}