Skip To Content

Athabasca University

Unit Exercises

  1. Implement and test the Calculator analyzed and discussed in Chapter 4: Implementation in Java (Poo et al., 2008) with AWT.
  2. Review the API documentation for the File class. Note that while the File instance is a directory, the list() method returns a list of files in a String array. Using this feature, implement a directory browser consisting of List and nonediting TextArea components. The former presents the set of files in a directory, while the latter displays the selected file.
  3. Using the drawRect() method in the Graphics class, implement a rectangle drawing application that paints rectangles of various colours and positions. Indicate the opposite corners of the rectangle by pressing and releasing the mouse button.
    1. Include a rubber-band effect to indicate the rectangle’s borders by selecting two opposite corners of the rectangle.
    2. After being minimized, are the existing rectangles redrawn when the frame is restored? Suggest a scheme to implement this requirement.
    3. Use the right-hand mouse button to erase rectangles that enclose the mouse position.

Updated July 30 2020 by FST Course Production Staff