matlab界面中text显示字符,如和使向edit text中输入的字符显示为'*'

icon1.gif

function mima

OldHandle = findobj( 'Type', 'figure', 'Tag', 'mimadenglu' ) ;

if ishandle( OldHandle )

close( OldHandle ) ;

end

fig = figure ;

scnsize=get(0,'screensize');

set(fig,'units','normalized','position',[0.3 0.2 0.4 0.6],...

'menubar','none','name','密码登陆窗口',...

'numbertitle','off','color',[0.925 0.914 0.847],'tag','mimadenglu');

font_size1=round(20*sqrt(scnsize(3)*scnsize(4)/(1024*768)));

font_size2=round(14*sqrt(scnsize(3)*scnsize(4)/(1024*768)));

uicontrol(fig,'style','text','units','normalized','pos',[0.1 0.63 0.8 0.15],'string','欢迎使用本系统',...

'fontsize',font_size1,'fontweight','bold','fontunits','normalized','bac',[0.925 0.914 0.847])

panel1=uipanel(fig,'units','normalized','pos',[0.15 0.3 0.7 0.15],'bac',[0.925 0.914 0.847]);

uicontrol(panel1,'style','edit','units','normalized','pos',[0.2 0.2 0.6 0.6],...

'string','','tag','edit1','backgroundcolor',[1 1 1],'string','请输入密码',...

'fontsize',font_size2,'fontunits','normalized','KeyPressFcn',...

['currKey = get(gcf,''Currentkey'');',...

'currChar = get(gcf,''Currentcharacter'');',...

'switch currKey;',...

'case {''backspace'',''delete''};',...

'Char = [];',...

'set(gcbo,''String'','''');',...

'drawnow;',...

'case ''return'';',...

'passChar = get(gcbo,''UserData'');',...

'if strcmp(passChar,''654321'');',...

'msgbox(''恭喜你记住了密码!!!'');',...

'else;',...

'msgbox(''密码输入错误!!!'');',...

'end;',...

'return;',...

'otherwise;',...

'oldChar = get(gcbo,''UserData'');',...

'Char = [oldChar,currChar];',...

'set(gcbo,''string'',char(''*''*ones(1,length(Char))));',...

'end;',...

'set(gcbo,''UserData'',Char);'])

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值