1. 功能
- 用户名输入
- 密码输入(隐藏密码,带星号)
- 输入正确错误提示
- 带背景图片
- 带logo修改
2. 界面
3. 源代码
【loginSys.m】
function loginSysclear;clc;Hd_login = figure('NumberTitle', 'off', 'Resize','off','Color',[0.753,0.753,0.753],'Name', '登录','tag','Hd_login');newIcon = javax.swing.ImageIcon('.\images\icon.png');figFrame = get(Hd_login,'JavaFrame'); figFrame.setFigureIcon(newIcon);set(Hd_login,'menubar','none','Unit','normalized','Position',[0.28,0.32,0.38,0.45]);Hd_axes = axes('units','normalized','position',[0 0 1 1],'tag','Hd_axes');uistack(Hd_axes,'down')II=imread('.\images\login.jpg');image(II)set(Hd_axes,'handlevisibility','off','visible','off');Hd_user = uicontrol('Parent',Hd_login,'Style','text',... 'String','用户名',... 'Units','normalized',... 'FontWeight','bold',... 'Background',[0.8 0.8 0.8],... 'ForegroundColor','black',... 'Units','normalized',... 'FontSize',25,... 'Enable','inactive',... 'tag','Hd_user',... 'Position',[0.1,0.68,0.25,0.15],... 'CallBack','');Hd_unserin = uicontrol('Parent',Hd_login,'Style','Edit',... 'String','',... 'FontWeight','bold',... 'ForegroundColor',[0.871,0.49,0],... 'Units','normalized',... 'FontSize',10,... 'HorizontalAlignment','left',... 'tag','Hd_unserin',... 'Position',[0.38,0.68,0.55,0.15],... 'CallBack','');Hd_passwd = uicontrol('Parent',Hd_login,'Style','text',... 'String','密 码',... 'Units','normalized',... 'FontWeight','bold',... 'Background',[0.8 0.8 0.8],... 'ForegroundColor','black',... 'Units','normalized',... 'FontSize',25,... 'Enable','inactive',... 'tag','Hd_passwd',... 'Position',[0.1,0.48,0.25,0.15],... 'CallBack','');jPass = javax.swing.JPasswordField;J_passwdin = javacomponent(jPass,[198 167 287 52]);hTip = uicontrol('style','text','visible','off','String','',... 'FontSize',18,... 'FontWeight','bold',... 'ForegroundColor','red',... 'position',[150 300 250 30]);uicontrol('pos',[100 80 140 40],'string','确认','FontWeight','bold',... 'ForegroundColor',[0 0 1],... 'FontSize',18,... 'callback',{@loginCheck,Hd_unserin,J_passwdin,hTip});uicontrol('pos',[290 80 140 40],'string','修改密码','FontWeight','bold',... 'ForegroundColor',[0 0 1],... 'FontSize',18,... 'callback',{@modifyPasswd,hTip});function modifyPasswd(~,~,hTip) set(hTip,'Visible','on','string','请联系开发人员!'); pause(3); set(hTip,'Visible','off');
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
【loginCheck.m】
function loginCheck(~, ~,hUser,hPass,hTip) user = get(hUser,'String') pswd = hPass.text if (strcmp(pswd, '111111') && strcmp(user,'FreeApe')) set(hTip,'Visible','off','string','密码正确'); out = '密码正确' else set(hTip,'Visible','on','string','用户名或密码错误!'); pause(2); set(hTip,'Visible','off'); out = '密码错误' end
0 0