This section illustrates you how to show Addition, Subtraction, Intersection, ExclusiveOR on one frame.
In this section, we are providing you an example which performs all the functions on one frame. Two classes Rectangle2D and Ellipse2D are used which provides rectangle and circle. A button panel is created containing the buttons. The ActionListener class is called to perform all the actions on these buttons.
The a.area(a2) add the areas of two shapes. The a. area(a2) subtract the area of a1 from a2. The a.intersect(a2) shows the common area between the two shapes. The a.exclusiveOr(a2) shows the uncommon area between the two shapes.
Here is the code of CalculateArea.java
Output will be displayed as:
Recommend the tutorial