Drawing a shape inside a JLabel

You can override the paint() method, call super.paint(g) and draw your shape as shown in following example.

Main.java:

import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
 
public class Main extends JFrame
{
   JLabel label;
 
   public Main() {
      label = new JLabel("This label will be overwritten with circles") {
         public void paint(Graphics g) {
            super.paint(g);
            double width = this.getSize().getWidth();
            double height = this.getSize().getHeight();
            g.setColor(Color.red);
            for (int i=0; i<width; i+=height) {
               g.drawOval(i, 0, (int) height, (int) height);
            }
         }
      };
      label.setForeground(Color.blue);
      label.setOpaque(true);
      getContentPane().add(BorderLayout.SOUTH, label);
 
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
            System.exit(0);
         }
      }); 
  
      setSize(350, 150);
   }
  
   public static void main(String []args) {
      Main main = new Main();
      main.setVisible(true);
   }
}