Here you can find the source of flashInfoMessage(final Component sourceComponent, final String message, int durationInMilliSecs)
public static void flashInfoMessage(final Component sourceComponent, final String message, int durationInMilliSecs)
//package com.java2s; //License from project: Open Source License import java.awt.Component; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class Main { public static void flashInfoMessage(final Component sourceComponent, final String message, int durationInMilliSecs) { JOptionPane pane = new JOptionPane(message, JOptionPane.INFORMATION_MESSAGE); final JDialog dialog = pane.createDialog(null, "Info message"); Timer timer = new Timer(durationInMilliSecs, new ActionListener() { public void actionPerformed(ActionEvent e) { dialog.setVisible(false); dialog.dispose();//from w w w . j a v a 2 s .c om } }); timer.setRepeats(false); timer.start(); dialog.setVisible(true); dialog.dispose(); } }