Why does JOptionPane have a constructor?

Archana Mani

The static methods available called "showXxxDialog" will satisfy many common dialogs, and are provided as a matter of convenience. Note that all dialogs displayed this way are modal.

You can create a new JOptionPane using the constructor as you have in your code. This gives you flexibility to create the pane however you want.

In addition, if you use the constructors, you can delay the showing of the dialog or make it non-modal.