This section illustrates you how to draw ellipse inside the rectangle.
To draw an Ellipse inside the rectangle, we have defined two classes Rectangle2D and Ellipse2D of package java.awt.geom.*. These classes provides a rectangle and a circle respectively.
By using draw() method of class Graphics2D, we can pass the values for the rectangle and the ellipse in the constructor of class Rectangle2D and Ellipse2D respectively to draw them.
To give the impressive and stylistic way to the outline of the specified shapes, we have used BasicStroke class. The method setStroke() sets the stroke for the Graphics2D context.
Here is the code of DrawRectangleAndEllipse.java
Output will be displayed as:
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: October 16, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles