sendMessage is a java.awt.TextArea object that accepts user messages to be
sent across the network to another user whose
IP Address is picked from toField (which is java.awt.Choice).
sendMessage() sends a message by constructing the DatagramPacket.
This is the implementation of the keyPressed() method from the KeyListener
that sendMessages is registered with.
public void keyPressed(KeyEvent ke){
if(ke.getKeyCode()==KeyEvent.VK_ENTER){
allMessages.append("localhost -
"+sendMessages.getText()+"\n");
try{
ms.sendMessage(cp.getClientIP(toField.getSelectedItem()),sendMessages.getText())\
;
}
catch(Exception e){}
sendMessages.setText("");
sendMessages.setCaretPosition(0);
}
}