Class DrawPanel

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----java.applet.Applet
                                   |
                                   +----DrawPanel

public class DrawPanel
extends Applet
implements ActionListener
Draw Panel Implements Action listener. An array (colorNames) is used to store the Names of the colors to be listed in the menu. A second array (colors) is used to store the Color value associated with the string value in colorNames. Sets the Color value using ActionListener. MouseEvent is used to detect whether or not the mouse event is the popupTrigger for the popup-menu. This will show the color menu at the location clicked in the applet. Then mouse event used to draw circles (left mouse click) at the location clicked or on entering and exiting the applet.


Constructor Index

 o DrawPanel()

Method Index

 o actionPerformed(ActionEvent)
actionPerformed Sets the foreground color to the color selected from the popup-menu.
 o init()
Create popup menu and add items
 o processMouseEvent(MouseEvent)
processMouseEvent Gets menu, and location of mouse click and shows the menu at the clicked location.

Constructors

 o DrawPanel
 public DrawPanel()

Methods

 o init
 public void init()
Create popup menu and add items

Overrides:
init in class Applet
 o processMouseEvent
 public void processMouseEvent(MouseEvent event)
processMouseEvent Gets menu, and location of mouse click and shows the menu at the clicked location. If mouse event is not the popup-menu then calls the graphics library to draw a solid oval bound by a specified rectangle. The left and top values are set to the x & y coordinates - 25, and the width and size are set to 20. Super processMouseEvent is called for other mouseListener events defined.

Parameters:
: - event: Processes mouse events
Returns:
: whether or not this mouse event is the popup-menu.
Overrides:
processMouseEvent in class Component
 o actionPerformed
 public void actionPerformed(ActionEvent event)
actionPerformed Sets the foreground color to the color selected from the popup-menu. getActionCommand returns the string label associated with the action. Then calls colorNamed with the label and then sets the foreground color.

Parameters:
: - event: Called when an action occurs.