如何在同一个监视器中获取JOptionPane.showOptionDialog?
How to get the JOptionPane.showOptionDialog in the same monitor?
我有一台连接了两台显示器的工作笔记本电脑。
我通常 运行 我的应用程序在 Monitor 2(这是一个外接显示器)上。
在我的应用程序中,我调用了一个 JOptionPane.showOptionDialog
,但问题是尽管 运行 正在执行,但该对话框总是出现在显示器(笔记本电脑屏幕)上监视器二中应用程序的所有计算。
我什至尝试了 getParent()
方法,但没有任何效果,我希望它与调用它的 JPanel 一起弹出。
这是我的 JOptionPane.showOptionDialog 示例:
JOptionPane.showOptionDialog(getParent() ,
jsr, //object
"MESSAGES",
JOptionPane.YES_NO_OPTION,
JOptionPane.ERROR_MESSAGE,
null,
options,
options[0]);
scrollPane.setViewportView(textArea);
validate();
repaint();
这很烦人,因为有时我认为应用程序只是崩溃了,因为监视器中没有任何内容,但实际上监视器中弹出了对话框 window。
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.
有没有其他方法可以解决这个问题?或者任何人都可以证明这个问题吗?
谢谢
试试JOptionPane.showMessageDialog(this, "Testing");
,根据this应该会有帮助。
我有一台连接了两台显示器的工作笔记本电脑。 我通常 运行 我的应用程序在 Monitor 2(这是一个外接显示器)上。
在我的应用程序中,我调用了一个 JOptionPane.showOptionDialog
,但问题是尽管 运行 正在执行,但该对话框总是出现在显示器(笔记本电脑屏幕)上监视器二中应用程序的所有计算。
我什至尝试了 getParent()
方法,但没有任何效果,我希望它与调用它的 JPanel 一起弹出。
这是我的 JOptionPane.showOptionDialog 示例:
JOptionPane.showOptionDialog(getParent() ,
jsr, //object
"MESSAGES",
JOptionPane.YES_NO_OPTION,
JOptionPane.ERROR_MESSAGE,
null,
options,
options[0]);
scrollPane.setViewportView(textArea);
validate();
repaint();
这很烦人,因为有时我认为应用程序只是崩溃了,因为监视器中没有任何内容,但实际上监视器中弹出了对话框 window。
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.
有没有其他方法可以解决这个问题?或者任何人都可以证明这个问题吗? 谢谢
试试JOptionPane.showMessageDialog(this, "Testing");
,根据this应该会有帮助。