2013-04-13 76 views
2

我有一個首選項頁面,有一些StringFieldEditor來保存不同的值。其中之一是爲了密碼。我希望密碼顯示爲星號或其他特殊字符。我只能使用org.eclipse.jface.preference.FieldEditor或其任何子類。請建議我如何做到這一點。eclipse字段編輯器的密碼

回答

2
password = new StringFieldEditor("passwd", "Password", getFieldEditorParent()) { 

@Override 
    protected void doFillIntoGrid(Composite parent, int numColumns) { 
     super.doFillIntoGrid(parent, numColumns); 

     getTextControl().setEchoChar('*'); 
    } 

}; 
0
StringFieldEditor passwordField = new StringFieldEditor("password", "Password", getFieldEditorParent()); 
passwordField.getTextControl(getFieldEditorParent()).setEchoChar('*'); 

addField(passwordField);