我试图得到一个弹出窗口显示在所有窗口的顶部,并保存在一个变量的值。但不知什么原因,弹出窗口显示在我所有的Windows后面。我怎样才能确保它突然出现在前面?我使用import javax.swing* String s = JOptionPane.showInputDialog(null,"PassWord ")
String s = JOptionPane.showInputDialog(null,"PassWord ")
6ie5vjzr1#
有几个选项可以在顶部显示弹出窗口:frame.setAlwaysOnTop(true); JOptionPane.showMessageDialog(frame, "Hello, World!"); https://docs.oracle.com/javase/7/docs/api/javax/swing/joptionpane.html#showinputdialog(java.awt.component,%20java.lang.object) inputDialog.setLocationRelativeTo(parent);
JOptionPane.showMessageDialog(frame, "Hello, World!");
inputDialog.setLocationRelativeTo(parent);
1条答案
按热度按时间6ie5vjzr1#
有几个选项可以在顶部显示弹出窗口:
frame.setAlwaysOnTop(true);
JOptionPane.showMessageDialog(frame, "Hello, World!");
https://docs.oracle.com/javase/7/docs/api/javax/swing/joptionpane.html#showinputdialog(java.awt.component,%20java.lang.object)inputDialog.setLocationRelativeTo(parent);