Reputation:
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.
Upvotes: 2
Views: 892
Reputation: 137442
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());
}
}
Upvotes: 2