import javax.swing.*;
import java.awt.*;
public class JRectanglesJavaExample extends JFrame
{
Container cntnr = getContentPane();
public JRectanglesJavaExample()
{
cntnr.setBackground(Color.GREEN);
cntnr.setLayout(new FlowLayout());
}
public void paint(Graphics gr)
{
super.paint(gr);
gr.setColor(Color.YELLOW);
gr.fillRect(50, 50, 130, 130);
gr.clearRect(60, 70, 60, 60);
}
public static void main(String[] ag)
{
JRectanglesJavaExample frm = new JRectanglesJavaExample();
frm.setSize(230,230);
frm.setVisible(true);
}
}