Exercise 1: Creating The ChatClient GUI Part 2 (Level 1)

In this exercise, you will implement the basic event handlers for the chat rom application. At this stage in the development of the ChatClient GUI, you will need to create the following event listeners:

 

 

 

Preparation 

Before you begin, make sure that you have changed directories to projects/ChatRommPrj/ using the  cd command in the terminal window.

cd ~/projects/ChatRoomPrj/

 

 

Task 1 - Modifying the ChatClient Program

Using a text editor, modify the ChatClient class source file in the project directory. This class must implement event listeners listed in the introduction on this exercise.

 

 

Task 2 - Compiling the ChatClient Program

On the command line, use the javac command to compile the ChatClient program.

 

 

Task 3 - Running the ChatClient Program

On the command line, use the java command to run the ChatClient program. Test the behavior of the event listeners you added.

 

 

Hints

Use the following hints during this exercise.

 

  • Have the listeners ( inner classes ) access the instance variables of their containing class to refer to the components like the output text area and the input field. Remember that you made the components instance variable in the previous lab.

  • Remember to import the java.awt.event package. 

  •  To get the text from a TextArea or TextField, you can use the getText method; to set the text use either the setText or append method.