Crie uma caixa de mensagem simples que desaparece após alguns segundos no Java

Gostaria de saber qual é a melhor abordagem para fazer com que uma caixa de mensagem comum do estilo JOptionPane desapareça após ser exibida por um período definido de segundo

Estou pensando em iniciar um thread separado (que usa um timer) do thread principal da GUI para fazer isso, de modo que a GUI principal possa continuar processando outros eventos etc. Mas como faço para criar a caixa de mensagem separada a linha desaparece e termina a linha corretamente. Obrigado

Edit: então é isso que eu proponho seguindo as soluções postadas abaixo

package util;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.Timer;

public class DisappearingMessage implements ActionListener
{
    private final int ONE_SECOND = 1000;

    private Timer timer;
    private JFrame frame;
    private JLabel msgLabel;

public DisappearingMessage (String str, int seconds) 
{
frame = new JFrame ("Test Message");
msgLabel = new JLabel (str, SwingConstants.CENTER);
msgLabel.setPreferredSize(new Dimension(600, 400));

timer = new Timer (this.ONE_SECOND * seconds, this);
// only need to fire up once to make the message box disappear
timer.setRepeats(false);
}

/**
 * Start the timer
 */
public void start ()
{
// make the message box appear and start the timer
frame.getContentPane().add(msgLabel, BorderLayout.CENTER);
frame.pack();
frame.setLocationRelativeTo(null); 
frame.setVisible(true);

timer.start();
}

/**
 * Handling the event fired by the timer
 */
public void actionPerformed (ActionEvent event)
{
// stop the timer and kill the message box
timer.stop();
frame.dispose();
}

public static void main (String[] args)
{
DisappearingMessage dm = new DisappearingMessage("Test", 5);
dm.start();
}
}

Agora, a questão é que, como eu vou criar várias instâncias dessa classe ao longo da interação entre o usuário e a GUI principal, eu me pergunto se o método dispose () limpa tudo corretamente todas as vezes. Caso contrário, posso acabar acumulando muitos objetos redundantes na memória. obrigado

questionAnswers(2)

yourAnswerToTheQuestion