copied partI files to partII

git-svn-id: svn://anubis/gvsu@18 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
josh 2008-02-17 22:16:50 +00:00
parent 46fa79c499
commit e22b39232c
2 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,27 @@
import java.awt.*;
public class ChatFrame extends Frame {
protected TextArea output;
protected TextField input;
protected Thread listener;
public ChatFrame (String title){
super (title);
setLayout (new BorderLayout ());
add ("Center", output = new TextArea ());
output.setEditable (false);
add ("South", input = new TextField ());
pack ();
show ();
input.requestFocus ();
}
public static void main (String args[]) {
new ChatFrame("Chat ");
}
}

View File

@ -0,0 +1,19 @@
import java.awt.event.*;
public class EnterListener extends KeyAdapter {
ChatClient client;
ChatFrame gui;
public EnterListener (ChatClient client, ChatFrame gui) {
this.client = client;
this.gui = gui;
}
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
client.sendTextToChat(gui.input.getText());
gui.input.setText("");
}
}
}