You are here: Home / Topics / Program to draw rectangle in Applet using drawRect() method in Java

Program to draw rectangle in Applet using drawRect() method in Java

Filed under: Java on 2023-10-16 07:02:34

//  Program to draw rectangle in Applet using drawRect() method.

import java.awt.*;
import java.applet.*;

/*
<applet code="DrawRectTest1a" width="200" height="100" >
</applet>
*/

public class  DrawRectTest1a  extends  Applet  
{
public void paint(Graphics g) 
{
 setBackground( Color.yellow );
 g.drawRect (10, 10, 180, 80);  
}
}

About Author:
J
Java     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.