I have a working laptop with two monitors connected to it. I usually run my application on Monitor two (which is an external monitor).
In my application I am calling a JOptionPane.showOptionDialog
, but the problem is that the dialog box always appear on the monitor one (which is the laptop screen) in spite of running and doing all the computation on the application in monitor two.
I even tried getParent()
method but nothing worked, I want it to pop up with the JPanel through which it is called.
Here is the sample of my JOptionPane.showOptionDialog:
JOptionPane.showOptionDialog(getParent() ,
jsr, //object
"MESSAGES",
JOptionPane.YES_NO_OPTION,
JOptionPane.ERROR_MESSAGE,
null,
options,
options[0]);
scrollPane.setViewportView(textArea);
validate();
repaint();
This is very annoying as sometime I thought the application just crashed as there is nothing in the monitor one but actually there is dialog window poped up in the monitor one.
EDIT:
This is a new question, as I dont have any problem in bringing the dialog box on top, I have also used the solution of
getParent()
method but it did not work. My main problem is of the monitors, If I am running an application monitor-2 everything should be displayed in monitor-2. But this is not happening in my case.
Is there any other way to deal this problem? Or can anyone justify this problem? Thanks
Try JOptionPane.showMessageDialog(this, "Testing");
, according to this it should help.