How do I set the text in it at the beginning when the dialog opens?
I have the following code that displays a JDialog
, it shows a text field, I assume it's a 开发者_StackOverflow中文版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);
Use:
pane.setInitialSelectionValue("foo");
to set the input value that is initially displayed as selected to the user.
精彩评论