2011-08-16 32 views
2

我有一個全屏(100%,甚至涵蓋任務欄)應用程序,它有時使用帶有PasswordBox的JOptionPane來請求密碼。我的問題是,當彈出窗口出現時,您可以在底部看到系統的任務欄。它看起來是這樣的:在全屏應用程序中產生一個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(); 

如果有人需要更多的代碼,我可以很容易地提供。我不知道如何解決這個問題以及從哪裏開始。我放棄了「專注」的想法,因爲當彈出窗口顯示它有焦點時。

+1

只是爲了清楚起見,這是Windows任務欄? – Jeremy

+0

在Windows中確實很好,Linux給我一些問題。目前正在使用Gnome進行RHEL測試 – n0pe

+0

考慮使用['getPassword()']的安全含義(http://download.oracle.com/javase/6/docs/api/javax/swing/JPasswordField.html#getPassword%28如圖所示。 – trashgod

回答

2

如果我沒有記錯的話,你應該通過父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()); 
    } 
} 
相關問題