秋天的萝卜

萝卜的哈工大博客

« MATLAB画的准周期结构

输入密码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;']);
 

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Arwen Build 90619 Code detection by Codefense  theme by BokeZhuti

Copyright;2009-2009 blog.hit.edu.cn All Rights Reserved 哈工大网络与信息中心