Here you can find the source of createPane(Component comp, String msg)
public static void createPane(Component comp, String msg)
//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.JDialog; import javax.swing.JOptionPane; import javax.swing.Timer; public class Main { public static void createPane(Component comp, String msg) { JOptionPane pane = new JOptionPane(msg); final JDialog dialog = pane.createDialog(comp, "INFORMATION"); Timer timer = new Timer(4000, new ActionListener() { public void actionPerformed(ActionEvent evt) { dialog.dispose();/* w w w . j ava 2s . c o m*/ } }); timer.setRepeats(false); timer.start(); dialog.show(); timer.stop(); dialog.show(false); } }