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

In this exercise, you will create a GUI for a chat room application. You will use a complex layout to position properly several GUI components in a frame.

 

Task 1 - Creating the ChatClient Program

Using a text editor, create the ChatClient class source file in the project directory. This class must implement teh GUI desing in Figure 10 - 1 on page Lab 10 - 2.

1.    Declare the ChatClient class.

2.     Add four atrributes to the ChatClient class to hold the GUI components.

3.        Add a public constructor that initializes each of the four GUI component attributes: The text area sould be 10 rows tall and 50 columns wide, the text field should be 50 columns wide, the send button should have word Send in the display, and the quit button should display a similar label.

4.    Create a launchFrame method that constructs tha layout of the components. Feel free to use nested panels and any layout managers that will help you construct the layout in the GUI design shown above.

5.     Create teh main method. This method will instantiate a new ChatClient object and then call the  launchFrame method.

 

 

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. You should see the GUI shown in Figure 10 - 1 on page Lab 10 - 2. If your GUI does not look exactly like the figure, then edit the code to tweak the design to match this figure.