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
  • 111,301
  • 67
  • 311
  • 403
Nyx
  • 1,203
  • 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
  • 657,433
  • 87
  • 1,179
  • 1,226