Drawing a Rectangle with rounded corners using Java 2D Graphics API

To draw a rectangle with rounded corners using the Java 2D graphics API is much like drawing a normal rectangle.
The only difference is that the static Float method takes additionally two arguments. Consider the code below:

The Float() method of the class RoundRectangle2D takes six arguments.
The first two represent the location of the upper left corner. Argument 3 and 4 represents the width and height of the rounded rectangle.
The last two arguments represent the width and height of the arc drawn in the corners.
This is what it looks like when drawn on a JFrame:

Ractangle with rounded corners drawn using Java 2D Graphics API

This is what the complete code of the JFrame class looks like:

Drawing a rectangle using Java 2D graphics API

Search for more Java info on this site here:
Custom Search

Please type any questions here.