import javax.swing.*; import java.awt.*; import java.awt.event.*; /**** * * Pop-up window to display the number of shapes in the workspace. * */ public class NumShapesDialog extends JOptionPane implements ActionListener { /** The workspace model. */ WorkSpace workSpace; /** Message prefix */ String prefix = "Number of shapes = "; /** * Construct with the given workspace. */ public NumShapesDialog(WorkSpace workSpace) { this.workSpace = workSpace; } /** * Respond to the actionPeformed, which comes for the menu item selection. */ public void actionPerformed(ActionEvent e) { showMessageDialog(null, prefix + (new Integer(workSpace.size())).toString()); } }