In this section, you will learn how to create rectangle image. This program used the Graphics2D class which extends the Graphic class and control all geometry or coordinate transformation and color management, text layout. The Java programming in java 2D API provides several classes. It defines that common geometry object such as lining drawing , rectangle Drawing , curve drawing and Circle. All types of Geometry classes parts are supported by java.awt.geom package.
In this program, you can also see how to used Rectangle2D for rectangle component. Define, first of all, class name for the rectangle component. The rectangle2D class describes a rectangle and is defined by the this location (x , y) coordinate and dimension (width , height).
Rectangle2D.Double(): This class is used to define a rectangle specified in double coordinate.
setPaint(): This component used for filling the color into the rectangle image.
Here is the code of this program:
Output this program:
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: March 13, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles