Page: (Bot) (Prev) (Next) Class: (Outline) (Summary) (Assign) (Answer) Course: (Cover) (Content) (Glossary)
IT508 - INTERNET PROGRAMMING - CLASS 7
ASSIGNMENT

To: (Readings) (Problems) (Exercises)

READINGS (Top)

  1. Read the article titled 100% Maintainable Java by Scott Ambler.

  2. Read chapters twenty two and twenty three in the text. The most important part of the reading is the code on pages 600 thru 603.

PROBLEMS (Top)

  1. The spreadsheet example used a GridLayout. Would there be any advantage in using a GridBagLayout to construct the spreadsheet?

  2. Outline code for a BorderPanel class that uses a GridBagLayout to emulate a BorderLayout. Creating this class is a useful academic exercise. How might this class also be useful in the real world?

  3. Consider the following constructor for a numeric keypad. It uses the private makeButton() method that was described on the GridBagLyout page:
      public class NumbPad extends Frame
      {
            ....
    

    public NumbPad() { //Construct superclass with title super("Numeric Keypad"); //Create grid bag layout GridBagLayout grid = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); //Set frame layout to grid bag this.setLayout(grid); //Assume all have equal weight gbc.weightx = 100.0; gbc.weighty = 100.0; gbc.fill = GridBagConstraints.BOTH; //Make enter and clear X Y W H buttonClr = makeButton("Clear", grid,gbc,0,0,1,1); buttonEnter = makeButton("Enter", grid,gbc,3,3,1,2); //Pad width to approximate width of Clear gbc.ipadx = 50; //Create operations X Y W H buttonDiv = makeButton("/",grid,gbc,1,0,1,1); buttonMul = makeButton("*",grid,gbc,2,0,1,1); buttonSub = makeButton("-",grid,gbc,3,0,1,1); buttonSub = makeButton("+",grid,gbc,3,1,1,2); buttonDot = makeButton(".",grid,gbc,2,4,1,1); //Make digits button0 = makeButton("0",grid,gbc,0,4,2,1); button1 = makeButton("1",grid,gbc,0,3,1,1); button2 = makeButton("2",grid,gbc,1,3,1,1); button3 = makeButton("3",grid,gbc,2,3,1,1); button4 = makeButton("4",grid,gbc,0,2,1,1); button5 = makeButton("5",grid,gbc,1,2,1,1); button6 = makeButton("6",grid,gbc,2,2,1,1); button7 = makeButton("7",grid,gbc,0,1,1,1); button8 = makeButton("8",grid,gbc,1,1,1,1); button9 = makeButton("9",grid,gbc,2,1,1,1); //Resize and validate this.resize(200,250); this.validate(); }

    1. Sketch the keypad that is produced by this code.
    2. What is the rationale behind the width and height that are specified in the resize() method call?

  4. StoneAge Computing wants to port some of their existing applications to modern technology. Their current user interface, which is character based, is shown in the following diagram.

    [STONEAGE INTERFACE]

    Write a Java class called MainWindow that extends Frame to implement this interface. Assume that the main display is a text area that uses the monospaced Courier font. The main display should get all of the additional height if the window is resized. Include a main() method that can be used to quickly test the appearance of the interface.

EXERCISES (Top)

Your work on these exercises will be very useful for the second graded problem.

  1. Get your own copy of the source code for the IntField class. Factor this class into a superclass and a subclass and then add a new subclass that can be used to get text. The resulting hierarchy should be:

    [FORM ITEMS]
    The FormItemText class should have a method that can be used to specify the valid values so that user input can be restricted.

  2. Get your own copy of the source code for a FormGridLayout class that is shown in the following class model:

    [FormGridLayout]

    Study the code to be sure you understand how an instance of this class would be constructed and used. The comments in the code conform to the Java Documentation Comment Syntax which means that you can run the javadoc utility against the class to produce an html document file. The command is:

        javadoc FormGridLayout.java
    
    If you view the resulting html file in the browser, you can read the formatted documentation but you will be missing all of the images for the various colored balls and headings that appear in web based documentation.
    You can, of course, copy these images from the CD-ROM and put them in the appropriate directory if you really want pretty documentation.

  3. Code an application class that has a main() method that constructs and instance of the class. The instance constructor should call a private initGui() method the builds the following user interface. Use an instance of the FormGridLayout class to add the components to the underlying GridBagLayout.

    [NAME FORM]


Page: (Top) (Prev) (Next) Class: (Outline) (Summary) (Assign) (Answer) Course: (Cover) (Content) (Glossary)

Prepared by David L. March -- Last Revised on October 10, 1998
COPYRIGHT © 1998 BY DAVID L. MARCH