0

I have the following code that displays a JDialog, it shows a text field, I assume it's a JTextField.

How do I set the text in it at the beginning when the dialog opens?

JOptionPane pane = new JOptionPane("", JOptionPane.QUESTION_MESSAGE);
pane.setWantsInput(true);
JDialog dialog = pane.createDialog(null, "Test");
dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
dialog.setVisible(true);
Bernhard Barker
  • 54,589
  • 14
  • 104
  • 138
Frank
  • 30,590
  • 58
  • 161
  • 244

1 Answers1

0

Use:

pane.setInitialSelectionValue("foo");

to set the input value that is initially displayed as selected to the user.

dogbane
  • 266,786
  • 75
  • 396
  • 414