copied partI files to partII
git-svn-id: svn://anubis/gvsu@18 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
46fa79c499
commit
e22b39232c
27
cs654/lab5/partII/ChatFrame.java
Normal file
27
cs654/lab5/partII/ChatFrame.java
Normal 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 ");
|
||||
}
|
||||
}
|
||||
|
19
cs654/lab5/partII/EnterListener.java
Normal file
19
cs654/lab5/partII/EnterListener.java
Normal 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("");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user