But we have chosen to design our own component for this purpose, which consists of a reddish oval with a number or operator inside. When we design our own component, there are several important points to note. One is that the component should have a constructor, to create new instances. This is important in setting up the bounding box for the component and for doing layout. A custom component may be a subclass of an AWT class like Canvas, or in 1.1, it may extend java.awt.Component directly.
Lightweight components can be more efficient, because of less overhead.
Finally, we should mention how event handling is done in this example. This is the method that actually does all the calculating work. When the mouse is clicked, we detect that, and dispatch in turn to the listener for the selected button. We could have the mouse clicks dispatch straight through to the docalc instance, but such an architecture is not clean. All Rights Reserved.