// FrontCmd.java // Command class to perform a front command. // Written by THC for CS 5 Lab Assignment 3. import java.awt.*; public class FrontCmd extends Command { // When the mouse is clicked, find the frontmost Shape in the drawing // that contains the mouse position. If there is such a Shape, then // have it move itself to the front of the drawing. public void executeClick(Point p, Drawing dwg) { // Find the frontmost Shape containing p. Shape s = dwg.getFrontmostContainer(p); if (s != null) // was there a Shape containing p? dwg.moveToFront(s); // yes, move it to the front of the drawing } }