import javax.swing.*;
import java.awt.*;
public class MyPanel extends JPanel {
@Override
public void paintComponent(Graphics g){
// clear the previous painting
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setColor(Color.blue);
g2.drawOval(0, 0, 20,20);
g2.fillOval(50,50,20,20);
}
}
g2.drawOval(int x,int y,int height, int width);
This method will draw an oval at specified x and y position with given height and width.
g2.fillOval(int x,int y,int height, int width); This method will fill an oval at specified x and y position with given height and width.