This section illustrates you how to subtract the area between the two figures in Graphics.
In the given example, the classes Rectangle2D and Ellipse2D are provided from the package java.awt.geom.*. These classes provides the rectangle and oval shape respectively. Object of class Area is created by passing 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 code subtract the area of rectangle over the oval:
| area1.subtract(area2); |
Here is the code of SubtractAreaExample.java
import java.awt.*;
|
Output will be displayed as:

|
Recommend the tutorial |
Ask Questions? Discuss: Subtract Area between two Figures
Post your Comment