In this exercise, you will implement the basic event handlers for the chat rom application. At this stage in the development of the
Create an
Create an ActionListener that copies the text from the input text field into the output text area when the Enter key is pressed in the input text field.
Create an ActionListener that will quit the program when the Quit button is pressed. (Hint - Use System.exit( 0 ).)
Create a WindowListener that will quit the program when the close widget is pressed on the frame.
Before you begin, make sure that you have changed directories to projects/ChatRommPrj/ using the cd command in the terminal window.
cd ~/projects/ChatRoomPrj/
Using a text editor, modify the
On the command line, use the
On the command line, use the java command to run the ChatClient program. Test the behavior of the event listeners you added.
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