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