输入密码GUI的小程序

功能说明:点击方框开始输入密码,按下按钮可以显示输入的密码。有效输入字符是0~9,a~z,A~Z

%
clc;clear;close all;
% keyPressFcn
keys=[];In=0;
a1=axes('Position',[0.1,0.1,0.3,0.23]);
set(a1,'Xtick',[],'Ytick',[]);box on;
set(a1,'ButtonDownFcn',['keys=[];In=1;',...
        'set(pe,''String'',''点击此处显示密码'');',...
        'set(he,''String'',[]);']);
text(0.1,0.8,'请点击此方框');
text(0.1,0.6,'开始输入密码');
he=uicontrol('Unit','Normalized','Position',[0.2,0.6,0.6,0.08],...
    'Style','Edit','Fontsize',18);
uicontrol('Unit','Normalized','Position',[0.2,0.7,0.6,0.08],...
    'Style','Text','Fontsize',18,...
    'String','只有输入0-9,a-z,A-Z是有效的');
pe=uicontrol('Unit','Normalized','Position',[0.2,0.5,0.6,0.08],...
    'Style','Push','Fontsize',14,'String','点击此处显示密码',...
    'Callback','set(pe,''String'',keys)');
set(gcf,'KeyPressFcn',['st=get(gcf,''CurrentCharacter'');',...
        'if [In>0.5]&[[47.5<st&st<57.5]|[64.5<st&st<90.5]|[96.5<st&st<122.5]];',...
        'keys=[keys,st];set(he,''String'',char(42*ones(1,length(keys))));',...
        'end;']);
 

点击微信扫一扫

关联阅读

最近留言

没有数据
扫描二维码访问
欢迎使用手机扫描二维码访问