Null passed in first argument: JOptionPane showMessageDialog

method signatures:

showMessageDialog(Component parentComponent, Object message)

 

or

showMessageDialog(Component parentComponent, Object message, String title, int messageType)

or

showMessageDialog(Component parentComponent, Object message, String title, int messageType, Icon icon)

first parameter is parentComponent :

Defines the Component that is to be the parent of this dialog box.

It is used in two ways:

 Frame that contains it is used as the Frame parent for the dialog box, and its screen coordinates are used in the placement of the dialog box. In general, the dialog box is placed just below the component.

Null, in which case a default Frame is used as the parent, and the dialog will be centered on the screen (depending on the L&F).

So there isn’t no parameter to set the position of the JOptionPane, but you could at least pass null as first parameter to be sure your JOptionPane is well visible and centered.

other resources :

Have something to add on Null passed in first argument ? Please add in comments.

Follow us on Facebook, Google Plus and Twitter to get more Tech News and reviews.

NO COMMENTS