Java examples for 2D Graphics:Rectangle
Draw Rounded Corner Rectangle and Square
import java.applet.Applet; import java.awt.Color; import java.awt.Graphics; public class Main { public void paint(Graphics g){ //draw a round cornered rectangle of width 50 & height 100 at (10,10) g.drawRoundRect(10,10,50,100,10,10); // w w w . ja v a 2 s.com //this will draw a round cornered square g.drawRoundRect(100,100,50,50,10,10); //set color to blue //setForeground(Color.blue); //draw filled rounded corner rectangle g.fillRoundRect(210,20,50,100,10,10); //draw filled square g.fillRoundRect(210,210,50,50,10,10); } }