import javax.swing.*;
import java.awt.Graphics;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;

public class rectangleP extends JPanel
{
 public void paintComponent(Graphics g)
 {
 Graphics2D g2=(Graphics2D)g;
 super.paintComponent(g);	 
 g2.setFont(new Font("Serif",Font.BOLD,24));	 
 g2.setColor(Color.red);
 this.setBackground(Color.MAGENTA);	 
 g2.setStroke(new BasicStroke(10.0f));
 Rectangle2D x=new Rectangle2D.Double(50,50,300,200);
 g2.draw(x);	 
 }
}

