2017-01-03 1 views

답변

2

setEchoChar() 메서드는 입력 된 문자를 표시할지 여부를 제어하는 ​​데 사용할 수 있습니다. 당신은 심지어 SWT.PASSWORD 스타일 플래그없이 Text 위젯을 만들고 단독으로 실행시 암호 문자를 변경할 수 있습니다

text.setEchoChar('\0'); 

:

는 다음과 같이 에코 문자를 지우, 실제로 입력 된 문자를 표시합니다.

대상 플랫폼 중 일부가 macOS와 같은 에코 문자 변경을 지원하지 않는 경우 SWT.PASSWORD 스타일 플래그없이 비밀번호 텍스트 필드를 다시 만들 수 있습니다. 예를 들어 :

Text oldText = text; 
Composite parent = oldText.getParent(); 
Control[] tabList = parent.getTabList(); 
// clone the old password text and dispose of it 
text = new Text(parent, SWT.BORDER); 
text.setText(oldText.getText()); 
text.setLayoutData(oldText.getLayoutData()); 
oldText.dispose(); 
// insert new password text at the right position in the tab older 
for(int i = 0; i < tabList.length; i++) { 
    if(tabList[ i ] == oldText) { 
    tabList[ i ] = text; 
    } 
} 
parent.setTabList(tabList); 
parent.requestLayout(); 
+0

에 메아리 문자를 설정 '\ 0'SWT.PASSWORD와 그렉-449이 지적 해 주셔서 감사합니다 @ 맥 OS –

+0

에서 작동하지 않습니다, 나는 대답에 대한 해결 방법을 추가했습니다. –

관련 문제