JHotDraw Pattern Language

Using Action Tool

Tools are commonly used for creation and connection events but it is also possible to use them to edit figure attributes. The abstract ActionTool class provides a starting point for tools to operate in this manner.

The JavaDraw example program (JHotDraw5.1/CH/ifa/draw/samples/JavaDraw) contains an example of an ActionTool. BorderTool creates a border around any figure that is clicked on when the tool is active.

ActionTool provides the action(Figure) method that when defined in a subclass, performs its action whenever the tool is applied to a figure (i.e. the mouse is clicked on it).

ActionTools are represented by buttons on the ToolBar.

Copyright Douglas Kirk