0

How can I prevent JOptionPane from closing until cancel or X button is clicked?

For example I have 3 text fields and buttons OK and Cancel if the user already filled the text fields and press the OK button the option pane will not close not until the user clicked the cancel or X button. Is there a simple way to do it?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Criz
  • 77
  • 4
  • 12

2 Answers2

0

Well you could have if the Joption is empty just show it again

APerson
  • 702
  • 6
  • 10
  • I would like the text on the textfields be there when the input is wrong or right so that the user can edit it and not redo the long typing in the textfields. – Criz Oct 06 '13 at 04:12
  • Than get the input from the textfield with input and then set the text of the new textfields. – APerson Oct 06 '13 at 04:16
0

instantiate JOptionPane yourself and add it to your own JDialog. JOptionPane - check user input and prevent from closing until conditions are met

Community
  • 1
  • 1
Irina Rapoport
  • 1,404
  • 1
  • 20
  • 37