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

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 listed in "Exercise 1: Creating the ChatClient GUI Part 2 (Level 1)" on page Lab 11 - 2.

 

 

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 "Exercise 1: Creating the ChatClient GUI Part 2 (Level 1)" on page Lab 11 - 2.

 

  1. Import the java.awt.event package.

  2. Add the ActionListener for the Send button. This listener must extract the text from the text field and display that text in the text area. Use an inner class for this listener.

  3. Add the ActionListener for the text filed. Can you use the same listener in Step 2?

  4. Add the WindowListener to the GUI frame. This listener must exit the ChatClient program. Use an inner class for this listener.

  5. Add the ActionListener for the Quit button. this listener must exit the ChatClient program. Use an anonymous inner class for this listener.

 

 

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.