【问题标题】:Spawning a JOptionPane in a full screen application shows the taskbar在全屏应用程序中生成 JOptionPane 会显示任务栏
【发布时间】:2011-08-16 18:59:01
【问题描述】:

我有一个全屏(100%,甚至包括任务栏)应用程序,它有时会使用带有 PasswordBox 的 JOptionPane 来要求输入密码。我的问题是当弹出窗口出现时,您可以在底部看到系统的任务栏。它看起来像这样:

    ----     popup
------------ taskbar
------------ fullscreen app

而我希望堆栈保持这样:

    ----     popup
------------ fullscreen app
------------ taskbar

只要我的应用程序正在运行,我就想完全隐藏任务栏。这是我正在使用的密码框类:

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());
    }
}

我这样调用它:

String tmpPASS = new PasswordBox().prompt();

如果有人需要更多代码,我可以轻松提供。我不确定如何解决这个问题以及从哪里开始。我放弃了“焦点”的想法,因为当弹出窗口出现时它有焦点。

【问题讨论】:

  • 为了清楚起见,这是 Windows 任务栏吗?
  • 在 Windows 中实际上很好,Linux 给了我一些问题。目前正在使用 Gnome 在 RHEL 上进行测试
  • 考虑使用getPassword() 的安全隐患,如图所示。

标签: java swing user-interface awt joptionpane


【解决方案1】:

如果我没记错的话,你应该将父 JFrame 作为第一个参数传递给 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());
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-07
    • 2011-01-22
    • 1970-01-01
    相关资源
    最近更新 更多