CS3283- GUI Programming  - Assignment 1 (on JFC Event Handling & Layout Manager)

Feb 2001   [10% of CA]

 

Please email a zipped file of your codes (with your matric no. as the filename to identify yourself, e.g. if your matric no is 12345, then your zipped file should be named “12345.zip”) by Mar 10, 2001 with the email subject as “cs3283-ass1:Your-Matric” to vtam@comp.nus.edu.sg. Also, you should print out a hard-copy of the codes and the output produced, and submit to Dr. Tam’s office (S17.4.20) by 12 noon on that day. 

 

1. User Interface and Layout Manager (4%)

Give the JFC codes to create the GUI as shown in Figure 1. There is no need to consider the event handling. The Layout management can adopt the mixture of flow layout manager and border layout manager (by default).

* Optionally, You also can consider other kind of layout manager, such as grid bag manager for a more precise way.

 

Figure 1

 

2. Event processing  - Separating the GUI and Application code (3%)

Continue with the single question given in your Tutorial Ex. 4, to change the background color, the following three ways can be taken:

Build an action object that can execute color change commands (The action class should be a subclass of javax.swing.AbstractAction). Try to analyze the Listener and event source and give the complete JFC Swing program to produce the output as shown in Figure 2.

 

Figure 2

 

3. Multicasting (3%)

Design a simple application of multicasting. We will have a frame that can spawn n multiple windows with the “New” Button. And, it can close all windows with the “Close all” button. Try to analyze the Listener and event source and give your complete JFC Swing program to achieve the GUI as shown in Figure 3.

 

            Figure 3