This is a closed notes, closed book exam.
THERE ARE PROBLEMS ON BOTH SIDES OF THE PAPER
java.awt.Frame
If e is the event object passed to the listener, then e.getSource() will return a reference to the source of the event.
java.awt.BorderLayout
The image is used to remember all drawing operations, otherwise when the window was repainted due to be covered/uncovered, iconified/deiconified etc., all of the results of the drawing operations would be lost.
The initial screen has the ``Do It!'' button at the top center and a large white area below that containing ``Click Do It! when ready'' somewhere near the center. When you click the button it button label changes to ``UnDo It!'' and the area below the button all turns black. Clicking the button again returns to the original screen. This cycle will repeat as long as you click the button.
The Frame would shrink down to be just big enough to show the button.
theCanvas.repaint() was deleted from DoIt? Specifically, when
if ever would the paint() method in MyCanvas get called without the
repaint() call?
The initial screen would appear as described earlier. However, clicking the button would not cause the large black area to appear, only the button label would change. Anything that caused the Frame to be partially obscured and then uncovered would cause paint to be called and the appropriate screen shown (either all black or with the text message near the center).
display.show();
/* your new line here */
Frame display = new Frame("Quiz4"); // from original
Button quit = new Button("Quit");
Quitter goodbye = new Quitter();
quit.addActionListener(goodbye);
display.add(quit,BorderLayout.SOUTH);
/*new class*/
import java.awt.*;
import java.awt.event.*;
class Quitter implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
}