Colocar texto no centro do painel

Boa noite
Pessoal estou testando componentes visuais e criei 4 paineis e gostaria de saber como colocar em cada painel o texto com o nome da cor dele no centro, são 4 paineis, um vermelho, um amarelo, um azul e verde. Os paineis exibo normalmente mas não consigo colocar texto muito menos no centro, tentei adicionar um JLabel mas não rolou e acho que também JLabel não deve ser a solução, Alguém saberia como fazer? Segue o código

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Main 
{
    private JFrame f;
    private JPanel p,p2,p3,p4;
    private String title = "";
    private Integer height = new Integer(400);
    private Integer width = new Integer(400);
    private JLabel vermelho;
    public Main() {
        f = new JFrame();
        p = new JPanel();
        p2 = new JPanel();
        p3 = new JPanel();
        p4 = new JPanel();
        vermelho = new JLabel("Vermelho");
        
        f.setSize(width.intValue(), height.intValue());
    }
    
    public Main(String title) {
        this();
        f.setTitle(title);
        this.title = title;
    }
    
     public Main(String title, Integer width, Integer height) {
        this(title);
        this.width = width;
        this.height = height;
    }
    
    
    public void launchFrame() {
       f.setLayout(null); //override default layout manager
       p.setBackground(Color.blue);
       p2.setBackground(Color.green);
       p3.setBackground(Color.red);
       p4.setBackground(Color.yellow);

       f.setBackground(Color.white);
       p.setSize(width.intValue()/2, height.intValue()/2 );
       p2.setSize(width.intValue()/2, height.intValue()/2 );
       p3.setSize(width.intValue()/2, height.intValue()/2 );
       p4.setSize(width.intValue()/2, height.intValue()/2 );
       //posiciona
       p.setLocation(0,0);
       p2.setLocation(0,height/2);
       p3.setLocation(width/2,0);
       p4.setLocation(width/2,height/2);
       vermelho.setBackground(Color.red);
       vermelho.setLocation(60,60);
      // p.setSize(100, 100);
       f.add(p);
       f.add(p2);
       f.add(p3);
       f.add(p4);
       f.add(vermelho);
       f.setVisible(true);
    }

    public static void main(String args[]) {
        Main window = new Main("Frame com painel");
        window.launchFrame();
    }
}

isso aqui coloca um texto no centro do jpainel p

       p.setLayout(new java.awt.GridBagLayout());
       JLabel label = new JLabel("Teste");
       p.add(label);

pesquise sobre os tipos de layout para containers no swing

vc tem que add o label ao panel para centralizar vc tem que gerenciar o layout!!

import javax.swing.*;
import java.awt.*;

public class Main {

    private JFrame f;
    private JPanel p, p2, p3, p4;
    private String title = "";
    private Integer height = new Integer(400);
    private Integer width = new Integer(400);
    private JLabel vermelho;

    public Main() {
        f = new JFrame();
        p = new JPanel();
        p2 = new JPanel();
        p3 = new JPanel();
        p4 = new JPanel();
        vermelho = new JLabel("Vermelho");

        f.setSize(width.intValue(), height.intValue());
    }

    public Main(String title) {
        this();
        f.setTitle(title);
        this.title = title;
    }

    public Main(String title, Integer width, Integer height) {
        this(title);
        this.width = width;
        this.height = height;
    }

    public void launchFrame() {
        f.setLayout(null); //override default layout manager  
        p.setBackground(Color.blue);
        p2.setBackground(Color.green);
        p3.setBackground(Color.red);
        p4.setBackground(Color.yellow);

        f.setBackground(Color.white);
        p.setSize(width.intValue() / 2, height.intValue() / 2);
        p2.setSize(width.intValue() / 2, height.intValue() / 2);
        p3.setSize(width.intValue() / 2, height.intValue() / 2);
        p4.setSize(width.intValue() / 2, height.intValue() / 2);
        //posiciona  
        p.setLocation(0, 0);
        p2.setLocation(0, height / 2);
        p3.setLocation(width / 2, 0);
        p4.setLocation(width / 2, height / 2);
        vermelho.setBackground(Color.WHITE);
        vermelho.setLocation(60, 60);
        // p.setSize(100, 100);  
        f.add(p);
        f.add(p2);
        f.add(p3);
        f.add(p4);
        p.setLayout(new GridBagLayout());
        p.add(vermelho);//vc tinha que add o label no panel
        f.setVisible(true);
    }

    public static void main(String args[]) {
        Main window = new Main("Frame com painel");
        window.launchFrame();
    }
}

Este material é muito bom para aprender sobre manager Layout e oficial da sun:
http://download.oracle.com/javase/tutorial/uiswing/layout/using.html

Valeu pessoal entendi e funcionou