0

In Swing, I am able to prompt the user for input using JOptionPane. The only problem this presents is the fact that the user can't change focus between the input box and the frame/content within it.

Is there any parameter I can put in to make it so that the focus is always on the frame. As a note, I have already tried requestFocus().

Thank you in advance.

Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417
Nyx
  • 1,273
  • 6
  • 19
  • 32

2 Answers2

4

The JOptionPane dialog is always modal. U can check this:

Can I use a Java JOptionPane in a non-modal way?

in order to bypass this behaviour.

Community
  • 1
  • 1
xyz
  • 211
  • 1
  • 3
1

The idea of JOptionPane is to show a modal dialog, which asks for confirmation or option, and to continue once the user has chosen an option. Without the chosen option, the program can't continue.

If you would like a non-modal dialog, then you'll need to construct it yourself, using JDialog.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255