Search code examples
javaswingjoptionpane

While I was coding java using JOptionPane I couldn't understand below line


JOptionPane.showInputDialog(Component compt, Object o, String string, int i, Icon icon);

in the above line I didn't understood any parameters and also I provided string in the place of object and it stills works. Can anybody explain correct procedure.


Solution

  • According to java docs

    • parentComponent - determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is used
    • message - the Object to display
    • title - the title string for the dialog
    • messageType - the type of message to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE
    • icon - an icon to display in the dialog that helps the user identify the kind of message that is being displayed