Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Glenn Duncan   on Mar 18 In Java Category.

  
Question Answered By: Mae Roberts   on Mar 18

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);

}
}

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on setCaretPosition() with 1.4.2 Or get search suggestion and latest updates.


Tagged: