Search code examples
javaswinguser-interfacejoptionpane

JOptionPane.showInputDialog with String in input field


I'm using JOptionPane.showInputDialog("correct the following string"); and want a certain string to be already entered in the input field of the dialog when the dialog opens. Is that possible with JOptionPane?


Solution

  • use this in place of JOptionPane.showInputDialog("correct the following string");

    String mystr = JOptionPane.showInputDialog(null,
                        "correct the following string", "correct the following string");