Spawning a JOptionPane in a full screen application shows the taskbar
I have a full screen (100%, even covers taskbars) application which sometimes asks for a password using a JOptionPane with a PasswordBox. My problem is that when the popup appears, you can see the system's taskbar at the bottom. It kind of looks like this:
---- popup
------------ taskbar
------开发者_运维技巧------ fullscreen app
whereas I want the stack to stay like this:
---- popup
------------ fullscreen app
------------ taskbar
As long as my application is running I would like to fully hide the taskbar. This is the password box class I'm using:
public class PasswordBox {
public String prompt() {
JPasswordField pass = new JPasswordField(10);
int action = JOptionPane.showConfirmDialog(null, pass,"Enter Password",JOptionPane.OK_CANCEL_OPTION);
return new String(pass.getPassword());
}
}
and I invoke it like this:
String tmpPASS = new PasswordBox().prompt();
If anyone needs more code I can easily provide it. I'm not sure how to tackle this problem and where to start. I gave up on the idea of "focus" because when the popup shows up it has focus.
If I'm not mistaken, you should pass the parent JFrame
as the first parameter to the JOptionPane
:
public class PasswordBox {
public String prompt(JFrame fatherFrame) {
JPasswordField pass = new JPasswordField(10);
int action = JOptionPane.showConfirmDialog(fatherFrame, pass,"Enter Password",JOptionPane.OK_CANCEL_OPTION);
return new String(pass.getPassword());
}
}
精彩评论