Java Swing How to - Make JOptionPane dialogs show up as a task on the taskbar








Question

We would like to know how to make JOptionPane dialogs show up as a task on the taskbar.

Answer

import javax.swing.JFrame;
import javax.swing.JOptionPane;
/*  ww w.  j a  v a2 s.  co m*/
public class Main {
  public static void main(String[] args) {

    JFrame frame = new JFrame();

    frame.setVisible(true);

    String message = JOptionPane.showInputDialog(frame,
        "Would this be enough?.", "My dialog asks....",
        JOptionPane.INFORMATION_MESSAGE);

    System.out.println("Got " + message);

    frame.dispose();
  }
}