This section illustrates you how to add area of two specified figures in Graphics.
In the given example, the classes Rectangle2D and Ellipse2D are provided by the package java.awt.geom.*. These classes provides the shape rectangle and oval respectively. Object of class Area is created to pass the object of class Shape into its constructor. Set the size of rectangle with rect.setFrame(150, 150, 150, 100) and size of oval with oval.setFrame(100, 100, 150, 100).
Following method adds the area of two shape:
| area1.add(area2); |
Here is the code of AddAreaExample.java
import java.awt.*;
|
Output will be displayed as:

|
Recommend the tutorial |
Ask Questions? Discuss: Add Area of Two Figures
Post your Comment