MATLAB: How to see the typed letter in GUI

guimask

I have acode below (in key press function) GUI
password = get(handles.edit1,'String');
key = get(handles.figure1,'currentkey');
key1=get(handles.figure1,'currentcharacter')
switch key
case 'backspace'
password = password(1:end-1); % Delete the last character in the password
otherwise
password = [password get(handles.figure1,'currentcharacter')] % Add the typed character to the password
end
SizePass = size(password) % Find the number of asterisks
if SizePass(2) > 0
asterisk(1,1:SizePass(2)) = '*'; % Create a string of asterisks the same size as the password
set(handles.edit1,'String',asterisk) % Set the text in the password edit box to the asterisk string
else
set(handles.edit1,'String','')
end
I have created a GUI with one edit boxThe above code is to mask the typed letter in edit box into asterisk,but i cannot see the typed password,then the variable password ,if i have typed 123 in edit box,the edit box show 3 asterisk but in that variable password it shows **3,y i get like this

Best Answer

Reading or changing the String of an edit handle gives odd results in a key press function callback.
I think Yair has a way of getting it to work using Java.
You may wish to look in the File Exchange for password boxes.