'how to configure joptionpane with no button to dispose()?

i would like to display a message while initialisation of data using a dialog.

But it does't want to close and I can't see what is wrong with this code :

final JOptionPane optionPane = new JOptionPane("Information ", JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[]{}, null);
JDialog dialog1 = optionPane.createDialog(null,"Wait for init");

dialog1.setAlwaysOnTop(true);
dialog1.setVisible(true);
dialog1.setModal(false);

dialog1.dispose();

Thank you



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source