How to Draw Rounded Corner Rectangles and Squares in Java


The example aims to draw rounded corner rectangles and squares in an applet window by drawRoundRect method in Java.

Source Code

package com.beginner.examples;

import java.applet.Applet;
import java.awt.Graphics;
 
public class DrawExample7 extends Applet{
 
	public void paint(Graphics g){

		//this will draw a rectangle
		g.drawRoundRect(10, 10, 20, 40, 10, 10);
		
		//this will draw a square
		g.drawRoundRect(100, 100, 30, 30, 10, 10);
		System.out.println("ok");
	}
}

Output:

ok

References

Imported packages in Java documentation:

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments