Unit Exercises
- Implement and test the Calculator analyzed and discussed in Chapter 4: Implementation in Java (Poo et al., 2008) with AWT.
- 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.
- 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.
- Include a rubber-band effect to indicate the rectangle’s borders by selecting two opposite corners of the rectangle.
- After being minimized, are the existing rectangles redrawn when the frame is restored? Suggest a scheme to implement this requirement.
- Use the right-hand mouse button to erase rectangles that enclose the mouse position.
Updated July 30 2020 by FST Course Production Staff