EN 605.482 GUI Development with the Java Foundation Classes

Homework 1

In this homework, you will become familiar with JFrames, JInternalFrames, and layout managers..

The requirements for this assignment are as follows.

Step 1: Use a JOptionPane to get a main window size from the user. The choices should be 400x400, 800x800, 1000x1000 pixels.

Step 2: Once the user has selected the size, create a single window (JFrame) that is the chosen size. It should contain a single JDesktopPane that takes up its internal space. Closing the window shall exit the program.

The JDesktopPane will implement some type of simple window management scheme other than the default behavior of placing all windows at (0,0). In addition, this object shall manage the placement of the iconified JInternalFrame icons so that they will always be visible and organized in the JDesktopPane. You shall create a class that inherits from JDesktopPane that will manage your windows. This class shall be documented properly so that it can be used by other people at a later time.

The desktop pane will contain four JInternalFrame windows. Each internal frame shall be 400x200 pixels in size, and shall be resizable, iconifiable, minizable and closable. Closing an internal frame will not exit the program. Each of the internal frames will contain different layouts, and have for its title the name of the layout it is "showcasing". The layouts shall be as follows:

  1. FlowLayout - This layout will contain two panels, one red, one green each of 100x50 pixels. Each panel will have a tooltip assigned to it, stating the color of the panel.
  2. BorderLayout - This layout will have a panel in all five locations.
    1. The top and bottom panels should be 20 pixels high
    2. The Side panels should be 40 pixels wide
  3. GridLayout – Create a 2x3 Grid of panels with a spacing of 5 pixels between elements
  4. GridBagLayout – Create a layout as follows
    1. All elements will fill their containing cell(s)
    2. The first element will be 50 pixels wide, and be in the first row and column
    3. The second element will be in the first column and second row
    4. The third element will be in the second column, second row
    5. The fourth element will be in the third column, second row
    6. The fifth element will span the third row
    7. The sixth element will be in the fourth row, and span the second and third columns
    8. The first column will not change size
    9. The second column will expand at a rate of 25% of the change of the window
    10. The third column will expand at a rate of 75% of the change of the window
    11. The insets should be 5 pixels on each side
    12. All columns will expand vertically at the same rate and will take up the vertical space in the window

 


Grading Criteria is as follows:

Item
Points
Program Runs w/ no exceptions
15
Correct Layout of Panels
20
JOptionPane usage
20
JDesktop Pane layout
20
JInternalFrame and JFrame behavior
10
Cover Page Complete
5
Neatness/Presentation
5
Extra Effort
5