java登陆界面代码(可以用,界面带照片)
java用户登录界面的代码
java用户登录界面的代码以下是一个简单的Java用户登录界面的代码示例,其中包括了GUI界面设计和用户验证的代码:```javaimport javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JTextField;import javax.swing.JPasswordField;import javax.swing.JButton;import java.awt.event.ActionListener;import java.awt.event.ActionEvent;public class LoginWindow extends JFrame implements ActionListener {private JLabel usernameLabel, passwordLabel;private JTextField usernameTextField;private JPasswordField passwordField;private JButton loginButton;public LoginWindow() {setTitle("用户登录");setSize(400, 200);setLocationRelativeTo(null);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);usernameLabel = new JLabel("用户名:");passwordLabel = new JLabel("密码:");usernameTextField = new JTextField();passwordField = new JPasswordField();loginButton = new JButton("登录");loginButton.addActionListener(this);setLayout(null);usernameLabel.setBounds(50, 30, 80, 25);passwordLabel.setBounds(50, 70, 80, 25);usernameTextField.setBounds(130, 30, 200, 25);passwordField.setBounds(130, 70, 200, 25);loginButton.setBounds(150, 120, 100, 25);add(usernameLabel);add(passwordLabel);add(usernameTextField);add(passwordField);add(loginButton);setVisible(true);}public void actionPerformed(ActionEvent e) {String username = usernameTextField.getText();String password = newString(passwordField.getPassword());if (isValidUser(username, password)) {System.out.println("用户登录成功!");// 在这里可以跳转到下一个界面} else {System.out.println("用户名或密码错误!");}}private boolean isValidUser(String username, String password) {// 在这里实现用户验证的代码// 比如查询数据库是否有该用户并且密码是否匹配等等// 如果验证成功则返回true,否则返回falsereturn false;}public static void main(String[] args) {new LoginWindow();}}```该代码创建了一个窗口界面,包括“用户名”和“密码”两个文本框,以及一个“登录”按钮。
qq登录界面设计java程序
zhanghao.setFont(new Font("宋体",Font.PLAIN,13));
this.add(zhanghao);*/
// zhanghaowb = new JLabel(new ImageIcon("2.png"));
zidongdenglu = new JCheckBox("自动登录");
zidongdenglu.setBounds(200, 190, 100, 30);
this.add(zidongdenglu);
jizhumima = new JCheckBox("记住密码");
jizhumima.setBounds(100, 190, 100, 30);
} catch (InstantiationException e1) {
// TODO 自动生成 catch 块
e1.printStackTrace();
} catch (IllegalAccessException e1) {
// TODO 自动生成 catch 块
e1.printStackTrace();
QQLogin w = new QQLogin();
w.setVisible(true);
}
});*/
new QQLogin();
}
public void mouseClicked(MouseEvent e) {
// TODO 自动生成方法存根
java用户登录的代码
button2=new JButton("取消");
text=new JTextField(20);
pass=new JPasswordField(20);
button1.setMnemonic(KeyEvent.VK_O);//设置按钮快捷键
button2.setMnemonic(KeyEvent.VK_C);
text.setText("用户名及密码正确!");
pass.setText("");
}
else{
text.setText("");
pass.setText("");
}
}
else
System.exit(0);//退出程序
}
else
System.exit(0);//退出程序
}
}
public class LoginFrame extends JFrame {
public static void main(String[] args) {
MyJPanel jp=new MyJPanel();//定义面板
jp.setBorder(BorderFactory.createTitledBorder("输入用户名和密码"));//设定边界
JFrame frame=new JFrame("用户登录");
private JLabel label1,label2;
private JTextField text;
private JPasswordField pass;
java学生管理系统大作业代码
java学生管理系统大作业代码Java学生管理系统是一个基于Java语言开发的学生信息管理系统,用于方便学校教务人员进行学生信息的管理和查询。
以下是该系统的代码实现。
1. 登录界面代码实现该界面是用户登录的入口,用户需要输入用户名和密码才能进入系统。
```javaimport javax.swing.*;import java.awt.*;import java.awt.event.*;public class Login extends JFrame implements ActionListener {JLabel lb1, lb2, lb3;JTextField txtName;JPasswordField txtPwd;JButton btnOK, btnCancel;String userName = "admin";// 默认用户名String password = "123456";// 默认密码public Login() {setTitle("学生信息管理系统登录");// 设置窗体标题setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 设置窗体关闭方式setSize(350, 200);// 设置窗体大小setLocationRelativeTo(null);// 设置居中显示setLayout(new BorderLayout());JPanel pNorth = new JPanel();lb1 = new JLabel("欢迎使用学生信息管理系统", JLabel.CENTER); lb1.setFont(new Font("微软雅黑", Font.BOLD, 20));pNorth.add(lb1);add(pNorth, BorderLayout.NORTH);JPanel pCenter = new JPanel();pCenter.setLayout(new GridLayout(3, 2));lb2 = new JLabel("用户名:", JLabel.RIGHT);pCenter.add(lb2);txtName = new JTextField(20);pCenter.add(txtName);lb3 = new JLabel("密码:", JLabel.RIGHT);pCenter.add(lb3);txtPwd = new JPasswordField(20);txtPwd.setEchoChar('*');// 设置密码框的回显字符pCenter.add(txtPwd);btnOK = new JButton("登录");pCenter.add(btnOK);btnCancel = new JButton("取消");pCenter.add(btnCancel);add(pCenter, BorderLayout.CENTER);btnOK.addActionListener(this);btnCancel.addActionListener(this);setVisible(true);// 显示窗体}public void actionPerformed(ActionEvent e) {if (e.getSource() == btnOK) {String name = txtName.getText();// 获取用户名String password = new String(txtPwd.getPassword());// 获取密码 if (name.equals(userName) && password.equals(password)) {setVisible(false);new MainFrame();} else {JOptionPane.showMessageDialog(Login.this, "用户名或密码错误!", "登录失败", JOptionPane.ERROR_MESSAGE);}} else if (e.getSource() == btnCancel) {txtName.setText("");txtPwd.setText("");}}public static void main(String[] args) {new Login();}}```2. 主界面代码实现该界面是系统的主界面,包含了菜单栏、工具栏和表格显示区域。
javaweb课程设计源码参考
javaweb课程设计源码参考JavaWeb课程设计源码参考一、引言JavaWeb课程设计是计算机科学与技术专业的一门重要课程。
在这门课程中,学生需要掌握JavaWeb开发的基本知识和技能,并通过实践来加深对所学知识的理解。
本文将为大家提供一些JavaWeb课程设计的源码参考,帮助学生更好地完成课程设计。
二、登录页面登录页面是JavaWeb课程设计中常见的一个功能模块。
下面是一个简单的登录页面源码参考:```java<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %><!DOCTYPE html><html><head><title>登录页面</title></head><body><form action="login" method="post"><label for="username">用户名:</label><input type="text" id="username" name="username"><br><br><label for="password">密码:</label><input type="password" id="password" name="password"><br><br><input type="submit" value="登录"></form></body></html>```三、登录功能实现登录功能是JavaWeb课程设计中的核心功能之一。
JAVA web用户登录完整代码
java action:LoginForm form=(LoginForm)actionForm;ActionMessages errors = new ActionMessages();System.out.println(";form.getAction()=";+form.getAction());if (";login";.equals(form.getAction())) {System.out.println(";----------------login--------------";);AuthCodeCookie authCodeCookie = new AuthCodeCookie(request,response);if (!authCodeCookie.getAuthCode().equals(form.getAuthCode())) {//验证码不正确errors.add(";error.login.authcode";, new ActionMessage(";error.login.authcode";));this.saveErrors(request, errors);return mapping.getInputForward();}User user = this.getUserService().get(form.getUserId());if(user==null){errors.add(";er";, new ActionMessage(";er";));this.saveErrors(request, errors);return mapping.getInputForward();}Util util = new Util();if(!util.hash(form.getPassword()).equals(user.getPassword())){errors.add(";error.login.password";, new ActionMessage(";error.login.password";));this.saveErrors(request, errors);return mapping.getInputForward();}// 一旦登录成功,创建sessionHttpSession session = request.getSession();UserSession userSession = new UserSession();userSession.setUser(user);session.setAttribute(ER_SESSION_KEY, userSession);//把UserSession传递到下个页面// 并且修改用户登录时间,登录次数+1user.setLastLoginDate(Util.getCurrentDate(";yyyyMMdd hhmmss";));user.setLoginTimes(Integer.valueOf(user.getLoginTimes().intValue()+1));this.getUserService().update(user);System.out.println(";----------------------------------------------------";) ;// // 获取用户对应的系统应用菜单List allModuleList = this.getModuleService().getModuleTree(Integer.parseInt(user.getMenuLevel()));//0代表根菜单// List allModuleList = this.getModuleService().getModuleTree(1);//0代表主菜单// System.out.println(";allModuleList.size=";+allModuleList.size()); // for(int i=0;i<;allModuleList.size();i++){//System.out.println(";";+((Module)allModuleList.get(i)).getModuleName());// }Iterator menu = allModuleList.iterator();Vector parentV = new Vector();Vector childV = new Vector();Module m;while (menu.hasNext()) {m = (Module) menu.next();if(user.getPermission().indexOf(";[";+m.getId()+";]";)!=-1){if (m.getParentId().intValue() == 0) {parentV.add(m);} else {childV.add(m);}}}request.getSession().setAttribute(";parentVector";, parentV);request.getSession().setAttribute(";childVector";, childV);System.out.println(";初始化完毕";);return mapping.findForward(";userPanel";);}jsp:<;%@ page contentType=";text/html;charset=UTF-8";%>;<;%@ taglib uri=";/WEB-INF/struts-bean.tld"; prefix=";bean";%>;<;%@ taglib uri=";/WEB-INF/struts-html.tld"; prefix=";html";%>;<;%@ taglib uri=";/WEB-INF/struts-logic.tld"; prefix=";logic";%>;<;jsp:useBean id=";user_session"; scope=";session";type=";erSession"; />;<;%er user = null;if (user_session != null)user = user_session.getUser();//根据权限获得菜单,这里权限用Telephone替代一下先String str = user.getTelephone();%>;<;html>;<;head>;<;meta http-equiv=";Content-Type"; content=";text/html; charset=UTF-8";>;<;title>;LEFT<;/title>;<;link rel=";stylesheet"; href=";css/style.css"; type=";text/css";>;<;script language=";JavaScript";>;<;!--function doExit(){if (confirm(";您确定要退出帐单门户系统吗?";)){window.open(";login.portal?action=logout";,";_parent";,";";);}}//-->;<;/script>;<;script language=";JavaScript";>;var w=200;function closenavi() {w-=200;if (w>;-10) {window.parent.testframeset.cols = ''+w+',*';repeat=setTimeout(";closenavi()";,10);}else {clearTimeout(repeat);w=200;}}function loginOutPage() {document.forms[1].SIGN_OFF.click();}function initIt(){divCount = document.all.tags(";DIV";);for (i=0; i<;divCount.length; i++) {obj = divCount(i);if (obj.className == ";child"; || obj.className == ";child1";) obj.style.display = ";none";;}}function expandIt(el) {obj = eval(";page"; + el);obj2 = eval(";main"; + el);if (obj.style.display == ";none";) {obj.style.display = ";block";;}else {obj.style.display = ";none";;}}onload = initIt;var judge=0;function expandall(o) {if (judge==0) {divCount2 = document.all.tags(";DIV";);for (i=0; i<;divCount2.length; i++) {obj2 = divCount2(i);if (obj2.className == ";child"; || obj.className == ";child1"; || obj2.style.display == ";none";){obj2.style.display = ";block";;}if (obj2.className == ";menu";){//obj2.all.tags('img')[0].src='images/treeimg/tminus.gif';obj2.all.tags('img')[0].src='images/openfolder1.gif';}}judge=1;o.src='images/icon-closeall.gif';o.alt='全部折叠';}else {divCount2 = document.all.tags(";DIV";);for (i=0; i<;divCount2.length; i++) {obj2 = divCount2(i);if (obj2.className == ";child"; || obj.className == ";child1"; || obj2.style.display == ";block";){obj2.style.display = ";none";;}if (obj2.className == ";menu";){obj2.all.tags('img')[0].src='images/folder1.gif';}}judge=0;o.src='images/icon-expandall.gif';o.alt='全部展开';}}function quit(form) {window.close()}function loginOutPage() {document.forms[0].SIGN_OFF.click();}<;/script>;<;/head>;<;body bgcolor=";#D8DADA"; class=";bodyTop";>;<;center>;<;table width=";161"; border=";0"; cellspacing=";0"; cellpadding=";0";>;<;tr>;<;td>;<;table style=";margin-top: 10px; margin-bottom: 10px"; width=";138";border=";0"; align=";center"; cellpadding=";0"; cellspacing=";0";>;<;tr>;<;td>;<;img src=";images/001.jpg"; width=";138"; height=";6";>;<;/td>;<;/tr>;<;tr>;<;td class=";msBack";>;<;table width=";130"; border=";0"; align=";center"; cellpadding=";3";cellspacing=";0";>;<;tr>;<;td width=";19";>;<;img src=";images/em44.gif"; width=";19"; height=";19";>;<;/td>;<;td class=";message";>;您有新的帐单信息<;/td>;<;/tr>;<;tr>;<;td>;<;img src=";images/em44.gif"; width=";19"; height=";19";>;<;/td>;<;td class=";message";>;您有新的支付信息<;/td>;<;/tr>;<;/table>;<;/td>;<;/tr>;<;tr>;<;td>;<;img src=";images/002.jpg"; width=";138"; height=";6";>;<;/td>;<;/tr>;<;/table>;<;/td>;<;/tr>;<;/table>;<;logic:iterate id=";module"; name=";parentVector";type=";com.worthtech.billportal.bean.Module";indexId=";index";>;<;%int i = ((ng.Integer) pageContext.findAttribute(";index";)).intValue();%>;<;div id=<;%=";main"; + i%>; class=";title";onClick=";expandIt(<;%=";"; + i%>;); return false";>;<;%if(str.indexOf(";[";+module.getId()+";]";)!=-1){%>;<;table class=";TableLeftTop"; style=";margin-top: 10px"; width=";138";border=";0"; cellspacing=";0"; cellpadding=";4";>;<;tr>;<;td background=";images/LeftMenuBack.jpg";>;<;div align=";center";>;<;%=module.getModuleName()%>;<;/div>;<;/td>;<;/tr>;<;/table>;<;%}%>;<;/div>;<;div id=<;%=";page"; + i%>; class=";child";>;<;table class=";TableLeftView"; width=";170"; border=";0"; cellspacing=";0";cellpadding=";0";>;<;logic:iterate id=";childModule"; name=";childVector";type=";com.worthtech.billportal.bean.Module";>;<;%if(str.indexOf(";[";+childModule.getId()+";]";)!=-1&;&;childModule.getParent ID().intValue()==module.getId().intValue()){%>;<;tr>;<;td width=";44";>;<;div align=";right";>;<;img src=";images/t.gif"; width=";19"; height=";20";>;<;/div>;<;/td>;<;td width=";161";>;<;a href=<;%=childModule.getActionURL()%>; target=";mainFrame";>;<;%=childModule.getModuleName()%>;<;/a>;<;/td>;<;/tr>;<;%}%>;<;/logic:iterate>;<;/table>;<;/div>;<;/logic:iterate>;<;table style=";margin-top: 10px"; width=";161"; border=";0";cellspacing=";0"; cellpadding=";2";>;<;tr>;<;td>;<;table width=";141"; border=";0"; align=";center"; cellpadding=";2";cellspacing=";0";>;<;tr>;<;td>;<;div align=";center";>;<;a href=";#"; onclick=";doExit();";>;<;imgsrc=";images/ico01.gif";width=";65"; height=";15"; border=";0";class=";MouseOver";>; <;/a>;<;/div>;<;/td>;<;td>;<;div align=";center";>;<;ahref=";user.portal?action=password";target=";mainFrame";>;<;imgclass=";MouseOver";src=";images/ico02.gif";width=";65"; height=";15"; border=";0";>;<;/a>;<;/div>;<;/td>;<;/tr>;<;/table>;<;/td>;<;/tr>;<;/table>;<;/center>;<;/body>;<;/html>;。
Java实现简单GUI登录和注册界面
Java实现简单GUI登录和注册界⾯本⽂实例为⼤家分享了Java实现简单GUI登录和注册界⾯的具体代码,供⼤家参考,具体内容如下先看效果图:登陆界⾯:注册界⾯:实现代码如下:⼀、登陆界⾯package cn.bms.view;import java.awt.Color;import java.awt.Dimension;import java.awt.Font;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.border.MatteBorder;import cn.bms.tools.GUITools;/** 登录窗⼝*/@SuppressWarnings("serial")public class AdminLogin extends JFrame {private JPanel contentPanel = new JPanel();// Label标签存放背景图⽚private JLabel label;// 设置按钮组件private JButton login = new JButton("登录"), register = new JButton("注册");private JLabel jlb1 = new JLabel("⽤户名:"), jlb2 = new JLabel("密码:"), jlbtitle = new JLabel("登录界⾯");// 设置⽂本框组件private JTextField admin = new JTextField(), password = new JTextField();public AdminLogin() {this.init();this.addListener();}private void init() {this.setTitle("管理员登陆界⾯");this.setSize(500, 350);GUITools.center(this);ImageIcon image1 = new ImageIcon("837878.jpg"); // 界⾯背景图⽚JLabel backLabel = new JLabel();backLabel.setIcon(image1);label = new JLabel(image1);label.setBounds(0, 0, 1000, 400);// 在LayeredPane最底层上添加两个带图⽚的标签,并且label2在label上⽅this.getLayeredPane().add(label, new Integer(Integer.MIN_VALUE));// 将内容⾯板设置为透明,就能够看见添加在LayeredPane上的背景。
QQ登录界面java代码
}
jp=newJPanel();
jp.setLayout(null);
jp_jlb1=newJLabel(newImageIcon("image/qqtou.gif"));
jp_jlb1.setBounds(18, 10, 85, 85);//设置标签位置前提是要空布局
jp_jtf=newJTextField("QQ号码/手机/邮箱");
this.add(jp,BorderLayout.CENTER);//放到中部
this.setIconImage(newImageIcon("image/qq.gif").getImage());//设置窗口上的qq小图片
this.setResizable(false);//不允许放大,改变窗口大小等
JFrame jf =newJFrame(title);
Containercontainer= jf.getContentPane();
lb1=newJLabel(newImageIcon("image/tou.gif"));
lb2=newJLabel(newImageIcon("image/qqtou.gif"));
this.setSize(380,275);
this.setLocation(500,200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setVisible(true);
}
jp_jb2.setFont(f1);
jp_jb2.setBounds(95, 120, 65, 21);
jp_jb3=newJButton("登录");
【Java】JavaWeb登录检查及界面跳转
【Java】JavaWeb登录检查及界⾯跳转场景 ⼀般javaweb⽹站都有⽤户登录,⽽有⼀些操作必须⽤户登录才能进⾏,常见流程:⽤户请求--》后台判断是否登录--》没登录跳转到登录界⾯,登录⽤户正常操作解决思路 在⽤过滤器过滤请求,判断是否登录,如果未登录,返回参数跳转的登录界⾯,登录了的请求放⾏具体实现 新建⼀个web⼯,参考: 新建⼀个LoginFilter过滤器类,继承Filter类1package com.test.login;23import java.io.IOException;4import java.io.PrintWriter;5import java.util.ArrayList;6import java.util.List;78import javax.servlet.Filter;9import javax.servlet.FilterChain;10import javax.servlet.FilterConfig;11import javax.servlet.ServletException;12import javax.servlet.ServletRequest;13import javax.servlet.ServletResponse;14import javax.servlet.http.HttpServletRequest;15import javax.servlet.http.HttpServletResponse;16import javax.servlet.http.HttpSession;1718public class LoginFilter implements Filter {1920public static List<String> pattenURL = new ArrayList<String>();2122 @Override23public void destroy() {24// TODO Auto-generated method stub2526 }2728 @Override29public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)30throws IOException, ServletException {3132 HttpServletRequest httpRequest = (HttpServletRequest) request;33 HttpServletResponse httpResponse = (HttpServletResponse) response;34 HttpSession session = httpRequest.getSession();35// 登陆url36 String loginUrl = httpRequest.getContextPath() + "/login.jsp";37 String url = httpRequest.getRequestURI().toString();3839// 注:在pattenURL中的全部不拦截 url.indexOf(urlStr) > -1 表⽰urlStr在url中出现过,出现就不拦截40for (String urlStr : pattenURL) {41if (url.indexOf(urlStr) > -1) {42 chain.doFilter(request, response);43return;44 }45 }4647//超时处理,ajax请求超时设置超时状态,页⾯请求超时则返回提⽰并重定向,session.getAttribute("")是获取到登录⼈的session信息48if (session.getAttribute("") == null) {49// 判断是否为ajax请求50if (httpRequest.getHeader("x-requested-with") != null51 && httpRequest.getHeader("x-requested-with").equalsIgnoreCase("XMLHttpRequest")) {52 httpResponse.addHeader("sessionstatus", "timeOut"); // 返回超时标识53 httpResponse.addHeader("loginPath", loginUrl);// 返回url54 chain.doFilter(request, response);// 不可少,否则请求会出错55 } else {56// alert('会话过期,请重新登录');57 String str = "<script language='javascript'>" + "window.top.location.href='" + loginUrl + "';</script>";58 response.setContentType("text/html;charset=UTF-8");// 解决中⽂乱码59try {60 PrintWriter writer = response.getWriter();61 writer.write(str);62 writer.flush();63 writer.close();64 } catch (Exception e) {65 e.printStackTrace();66 }67 }68 } else {69 chain.doFilter(request, response);70 }71 }7273/**74 * 过滤器初始化调⽤⽅法在pattenURL中的全部不拦截,所以上⾯会使⽤:path.indexOf(urlStr) > -175*/76 @Override77public void init(FilterConfig config) throws ServletException {78 pattenURL.add("login.jsp");// 登录jsp79 pattenURL.add("login.do");// 登录⽅法80 pattenURL.add("css");// css81 pattenURL.add("image");// image82 pattenURL.add("js");// js83 pattenURL.add("fonts");// fonts8485 }8687 } 在web.xml中注册过滤器1<?xml version="1.0" encoding="UTF-8"?>2<web-app version="3.0" xmlns="/xml/ns/javaee"3 xmlns:xsi="/2001/XMLSchema-instance"4 xsi:schemaLocation="/xml/ns/javaee /xml/ns/javaee/web-app_3_0.xsd">56<display-name>test-login</display-name>78<!-- 登录过滤器 -->9<filter>10<description>登录过滤器</description>11<filter-name>loginFilter</filter-name>12<filter-class>com.test.login.LoginFilter</filter-class>13</filter>14<filter-mapping>15<filter-name>loginFilter</filter-name>16<url-pattern>/*</url-pattern>17</filter-mapping>1819<welcome-file-list>20<welcome-file>index.jsp</welcome-file>21</welcome-file-list>2223</web-app> 引⼊⼀个全局的js。
Jsp学生信息管理系统登录验证全代码
1.jsp登录界面 Login.jspNo.:00000000000000587 <%@page language="java"contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%><html><head><meta http-equiv="Content-Type"content="text/html;charset=UTF-8"><title>用户登录界面</title></head><form action="LoginServlet"method="post"><body bgcolor="blue"><marquee direction="right"onmouseover="stop()"onmouseout="start()"style="font-family: 楷体_GB2312"><p><font size="10px"color="red">学生信息信息管理系统</font></p></marquee><table align=center width="237"><tr><td><table width=100%><tr><td colspan=6><font size=2><div id="b2bContent"style="FILTER: revealTrans(Duration = 1, Transition =</font></td></tr><tr><td align=center STYLE='cursor: hand'><font size=2><div class="b2bbutton"id="bt0"onclick="javascript:showPage(0);clearTimeout(theTimer);theTimer=s etTimeout('turnPage()',speed);checkBt();">1</div></font></td><td align=center STYLE='cursor: hand'><font size=2><div class="b2bbutton"id="bt1"onclick="javascript:showPage(1);clearTimeout(theTimer);theTimer=s etTimeout('turnPage()',speed);checkBt();">2</div></font></td><td align=center STYLE='cursor: hand'><font size=2><div class="b2bbutton"id="bt2"onclick="javascript:showPage(2);clearTimeout(theTimer);theTimer=s etTimeout('turnPage()',speed);checkBt();">3</div></font></td><td align=center STYLE='cursor: hand'><font size=2><div class="b2bbutton"id="bt3"onclick="javascript:showPage(3);clearTimeout(theTimer);theTimer=s etTimeout('turnPage()',speed);checkBt();">4</div></font></td><td align=center STYLE='cursor: hand'><font size=2><div class="b2bbutton"id="bt4"onclick="javascript:showPage(4);clearTimeout(theTimer);theTimer=s etTimeout('turnPage()',speed);checkBt();">5</div></font></td><td align=center STYLE='cursor: hand'><font size=2><div class="b2bbutton"id="bt5"onclick="javascript:showPage(5);clearTimeout(theTimer);theTimer=s etTimeout('turnPage()',speed);checkBt();">6</div></font></td></tr></table><script language="javascript">b2bStr = new Array();b2bStr[0]= "<div style='float:left; width:100%;overflow:hidden;'><a href=1.gif target=_blank><img src=1.gif width=214px height=145px border=0></a><br><a target=_blank title=太阳岛公园一角 href=1.gif>太阳岛公园一角</a></div>";width:100%;overflow:hidden;'><a href=2.gif target=_blank><img src=2.gif width=214px height=145px border=0></a><br><a target=_blank title=太阳岛公园湖光山色 href=2.gif>太阳岛公园湖光山色</a></div>";b2bStr[2] = "<div style='float:left; width:100%;overflow:hidden;'><a href=3.gif target=_blank><img src=3.gif width=214px height=145px border=0></a><br><a target=_blank title=哈尔滨雪雕 href=3.gif>哈尔滨雪雕</a></div>";b2bStr[3] = "<div style='float:left; width:100%;overflow:hidden;'><a href=4.gif target=_blank><img src=4.gif width=214px height=145px border=0></a><br><a target=_blank title=镜泊湖 href=4.gif>镜泊湖</a></div>";b2bStr[4] = "<div style='float:left; width:100%;overflow:hidden;'><a href=5.gif target=_blank><img src=5.gif width=214px height=145px border=0></a><br><a target=_blank title=太阳岛公园瀑布 href=5.gif>太阳岛公园瀑布</a></div>";b2bStr[5] = "<div style='float:left; width:100%;overflow:hidden;'><a href=6.gif target=_blank><img src=6.gif width=214px height=145px border=0></a><br><a target=_blank title=镜泊湖夜色 href=6.gif>镜泊湖夜色</a></div>";var page=0;var speed=3000;function showPage(id){setTransition();b2bContent.innerHTML=b2bStr[id];b2bContent.filters.revealTrans.play();}function turnPage(){showPage(page);theTimer=setTimeout("turnPage()", speed);checkBt();page++;if(page>=6) page=0;}function checkBt(){for(var i=0;i<6;i++){btObj=eval('bt'+i);if(page==i){btObj.style.color='#FFFFFF';btObj.style.backgroundCol or='#FF781C';}else{btObj.style.color='#000000';btObj.style.backgroundColor='#F7 F7F7';}}}function setTransition(){b2bContent.filters.revealTrans.Transition=Math.round(Math.random( )*23);b2bContent.filters.revealTrans.apply();}turnPage();</script></TD></TR></table><hr color="green"width="540"><table align="center"><tr><td>用户名:<input type="text"name="username"size="8" maxlength="6"></td></tr><tr><td>密 码:<input type="password" name="password"size="10"maxlength="6"></td></tr><tr><td><input type="submit"value="登录"> <input type="reset"value="取消"></td></table></form></body></html>2.java代码(1)User.Java 定义的属性和数据库中的字段相对应package com.softeem.dt;public class User {private int id;private String username;private String password;private String xh;private String college;public int getId(){return id;}public void setId(int id){this.id = id;}public String getUsername() {return username;}ername = username;}public String getPassword() {return password;}public void setPassword(String password) { this.password = password;}public String getXh() {return xh;}public void setXh(String xh) {this.xh = xh;}public String getCollege() {return college;}public void setCollege(String college) { this.college = college;}}(2)UserDAO.java 操作数据库tb_user,验证用户登录package com.softeem.dao;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import com.softeem.db.DBManager;import er;public class UserDAO {/***验证用户登录*@return*/public boolean checkDenglu(User user) {boolean flag = false;// 获得数据库连接Connection conn = DBManager.getConnection();// 用select * from查询数据库中的所有字段String sql = "select count(*) from tb_user where username=? and password=?";try {PreparedStatement pst = conn.prepareStatement(sql);pst.setString(1, user.getUsername());pst.setString(2, user.getPassword());ResultSet rs = pst.executeQuery();while (rs.next()) {int count = rs.getInt(1);//用count和0比较,若大于0表示该用户存在,否则不存在if(count > 0){flag = true;}}} catch (SQLException e) {e.printStackTrace();}return flag;}}3.LoginServlet,点击登录跳转到服务器端package com.softeem.servlet;import java.io.IOException;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import er;/*** Servlet implementation class LoginServlet*/public class LoginServlet extends HttpServlet {private static final long serialVersionUID = 1L;/*** @see HttpServlet#HttpServlet()*/public LoginServlet() {super();}/*** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)*/protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { super.doGet(request, response);}/*** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)*/protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //获取表单数据//处理乱码request.setCharacterEncoding("utf-8");String username = request.getParameter("username");String password = request.getParameter("password");//封装到user对象中User user = new User();user.setUsername(username);user.setPassword(password);//调用dao的checkLogin方法UserDAO dao = new UserDAO();boolean flag = dao.checkLogin(user);String message = null;String path = null;if(flag){message = "登录成功";path="success.jsp";request.getSession().setAttribute("user", user);}else{message ="对不起密码错误,请重新输入!";path="fail.jsp";}//response返回messageresponse.setCharacterEncoding("utf-8");response.getWriter().write(message);*///属于服务器跳转,浏览器地址栏没有发生改变request.getRequestDispatcher(path).forward(request,response);}}青年人首先要树雄心,立大志,其次就要决心作一个有用的人才。
学校图书馆管理系统(java)
图书管理系统〔java〕本系统将会涉及到图书馆日常管理工作的根本常见细节,诸如新图书的入库登记,图书馆所有书籍的分类管理,图书的查询,图书的借阅、退还手续的登记,费旧图书的清理撤除等,本系统所要实现的这些功能根本上涵盖了图书馆的日常管理工作,根本能够满足校园图书馆的工作人员的管理需要。
在对本系统的具体开发过程当中,将采用Java语言进展开发,以Access实现后台数据库,本系统是完全基于图形化用户界面(GUI)的单机版本。
【关键字】信息化软件工程软件生命周期图形化用户界面AbstractThe full name of our System is: The Management Information System of Campus’s Library. At present, the computer technology is developing ever-growing, and the campus’s information construction also have pushing on, by contrast, the method of management in many university library is still by man, the library’workers must face to the large number of books, and also face to fall into the trouble. Actually, the work can be done by the computer which have a management information system. Then the heavy work will not be done by people, the library’workers can use computer to manage the books, and the everyday work will be easy.This is the goal which our system want to achieve finally.The principle of development to our system will be following with Software Engineering, we use the traditional model which be called Waterfall, and the course of development will be divided into six stage. We will develop the system in sequence.Our system contains many operations about library’s everyday work, such as Register New Books, Classify Books according to their subjects, Find Books, Dispose old books, and so on, our system can finish all of the work, and can meet the requirements of the library’sworkers.During the development of our system, we use the tool of JAVA to develop it, our system is on the basis of the Access Database.【KeyWords】Management Information System, Software Engineering, Ja目录一引论1〔一〕问题的定义1〔二〕可行性分析1〔1〕技术可行性1〔2〕经济可行性2二需求分析3数据库需求分析3〔1〕数据流图3〔2〕数据库逻辑构造设计4〔3〕数据库概念构造设计5 三系统设计6〔一〕总体设计6〔二〕详细设计6〔1〕各个模块的介绍6〔2〕流程图7〔3〕数据字典7〔4〕代码实现8四总结13五致谢14六参考文献14一引论〔一〕问题的定义首先,图书馆的管理直接关系到我们大学生如何更好的使用图书,更充分的利用现有资源学习,提高自身素质。
Android手机通用登陆界面代码设计
Toast.makeText(HomeActivity.this, "Congrats: Login Successfull", Toast.LENGTH_LONG).show();
public class LoginDataBaseAdapter {
static final String DATABASE_NAME = "login.db"; static final int DATABASE_VERSION = 1; public static final int NAME_COLUMN = 1; // TODO: Create public field for each column in your table. // SQL Statement to create a new database. static final String DATABASE_CREATE = "create table "+"LOGIN"+
// Insert the row into your table db.insert("LOGIN", null, newValues); ///Toast.makeText(context, "Reminder Is Successfully Saved", Toast.LENGTH_LONG).show(); } public int deleteEntry(String UserName) { //String id=String.valueOf(ID); String where="USERNAME=?"; int numberOFEntriesDeleted= db.delete("LOGIN", where, new String[]{UserName}) ; // Toast.makeText(context, "Number fo Entry Deleted Successfully : "+numberOFEntriesDeleted, Toast.LENGTH_LONG).show();
java简单图形用户界面代码
}catch(FileNotFoundException e1){
e1.getStackTrace();
}catch(IOException e2){
e2.getStackTrace();
}
}
}
if(e.getSource()==registerBtn){
JFrame re=new Register();
centerPanel11=new JPanel();
centerPanel12=new JPanel();
//标题
titleLbl=new JLabel("欢迎进入考试系统");
titleLbl.setFont(new Font("隶书",Font.BOLD,24));
northPanel.add(titleLbl);
if (name.equals("")){
JOptionPane.showMessageDialog(null, "用户名不能为空,请重新输入用户名", "用户名空提示", JOptionPane.OK_OPTION);
userTxt.requestFocus();
return;
}
else if (pwd.equals("")){
//定义组件
JPanel northPanel,southPanel,centerPanel,centerPanel1,centerPanel11,centerPanel12;
JButton loginBtn,registerBtn,cancalBtn;
JLabel userLbl,passwordLbl,titleLbl;
java实现单点登录,图例及相关代码
java实现简单的单点登录摘要:单点登录(SSO)的技术被越来越广泛地运用到各个领域的软件系统当中。
本文从业务的角度分析了单点登录的需求和应用领域;从技术本身的角度分析了单点登录技术的内部机制和实现手段,并且给出Web-SSO和桌面SSO的实现、源代码和详细讲解;还从安全和性能的角度对现有的实现技术进行进一步分析,指出相应的风险和需要改进的方面。
本文除了从多个方面和角度给出了对单点登录(SSO)的全面分析,还并且讨论了如何将现有的应用和SSO服务结合起来,能够帮助应用架构师和系统分析人员从本质上认识单点登录,从而更好地设计出符合需要的安全架构。
关键字:SSO, Java, J2EE, JAAS1 什么是单点登陆单点登录(Single Sign On),简称为SSO,是目前比较流行的企业业务整合的解决方案之一。
SSO的定义是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统。
较大的企业内部,一般都有很多的业务支持系统为其提供相应的管理和IT服务。
例如财务系统为财务人员提供财务的管理、计算和报表服务;人事系统为人事部门提供全公司人员的维护服务;各种业务系统为公司内部不同的业务提供不同的服务等等。
这些系统的目的都是让计算机来进行复杂繁琐的计算工作,来替代人力的手工劳动,提高工作效率和质量。
这些不同的系统往往是在不同的时期建设起来的,运行在不同的平台上;也许是由不同厂商开发,使用了各种不同的技术和标准。
如果举例说国内一著名的IT公司(名字隐去),内部共有60多个业务系统,这些系统包括两个不同版本的SAP的ERP系统,12个不同类型和版本的数据库系统,8个不同类型和版本的操作系统,以及使用了3种不同的防火墙技术,还有数十种互相不能兼容的协议和标准,你相信吗?不要怀疑,这种情况其实非常普遍。
每一个应用系统在运行了数年以后,都会成为不可替换的企业IT 架构的一部分,如下图所示。
随着企业的发展,业务系统的数量在不断的增加,老的系统却不能轻易的替换,这会带来很多的开销。
登录页面HTML+CSS+JS代码
网页效果截图:源码:HTML代码(login.html)<!DOCTYPE html><html><head lang="zh-CN"><title>表单登录页面</title><meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1"><link href="login.css" rel="stylesheet" type="text/css"/><link href="dist/css/bootstrap.min.css" rel="stylesheet" type="text/css"/> </head><body><div class="form-box"><div class="welcom"><span>欢迎您的到来</span></div><div class="input-box"><form class="form-horizontal" role="form" action="/" method="POST" enctype="text/plain"><div class="form-group "><label for="username" class="control-label col-md-3">Username:</label><div class="col-md-9"><input type="text" class="form-control" id="username" placeholder="请输入用户名"/><label class="nameinfo"></label></div></div><div class="form-group"><label for="password" class="control-label col-md-3">Password:</label><div class="col-md-9"><input type="password" maxlength="10" class="form-control" id="password" placeholder="请输入密码"/><label class="passwordinfo"></label></div></div><div class="submit-button"><button type="button"><span>Login</span></button></div></form></div></div><script src="jquery.min.js"></script><script src="dist/js/bootstrap.min.js"></script><script type="text/javascript" src="login.js"></script><!-- noscript标签检查脚本是否被禁用--><noscript><div>脚本已被禁用了,〒_〒...</div></noscript></body></html>CSS代码(login.css)*{padding:0;margin:0;}body {/* overflow:scroll; */font-family:Georgia;color:#000;}.form-box {width:470px;height:296px;margin:100px auto;border:3px #ADFF2F solid;background-color:#C5FF6D;border-radius:8px;}.welcom {width:100%;height:52px;line-height:52px;text-align:center;font-size:30px;font-family:Microsoft YaHei;font-weight:bold;border-bottom:1px #ADFF2F solid; }.input-box {position:relative;width:100%;height:248px;padding-top:30px;}.form-group {width:100%;height:50px;line-height:50px;}.form-group label,.form-group input { display:block;height:40px;font-size:16px;}.submit-button button {position:absolute;top:190px;left:2%;width:96%;height:42px;line-height:42px;border-style:none;border:2px #75FF58 solid;border-radius:3px;background-color:#86FF6D;}.submit-button span {font-size:20px;font-weight:bold;}JS代码:(login.js)$(function(){//设定两个标志,判断是否满足提交的条件var ok1=false;var ok2=false;//设定键盘事件,回车换行$(".form-control").keydown(function(event){//判断是否是回车键if(event.which == '13'){if($(this).val().length == 0){}else{var currIndex = $(this).index(':input');$(':input:eq('+(currIndex+1)+')').focus();}}});// 验证用户名$('input[id="username"]').blur(function(){var nameform=$(this).val();// 验证是否输入用户名if($(this).val() == ""){$(".nameinfo").html("用户名不能为空!");$(".nameinfo").css({"color":"red","font-family":"KaiTi","font-size":"16px"});}// 验证用户名是否大于六位else if($(this).val().length < 6){$(".nameinfo").html("用户名至少为6位!");$(".nameinfo").css({"color":"red","font-family":"KaiTi","font-size":"16px"});}//验证用户名格式是否正确elseif(!nameform.match(/^[a-zA-Z][a-zA-Z0-9@]*$/)){$(".nameinfo").html("用户名格式不正确!");$(".nameinfo").css({"color":"red","font-family":"KaiTi","font-size":"16px"});}else{$(".nameinfo").html("输入正确");$(".nameinfo").css({"color":"green","font-family":"KaiTi","font-size":"16px"});//验证通过,将标志位置为trueok1 = true;}});//验证密码$('input[id="password"]').blur(function(){if($(this).val() == "" ){$(".passwordinfo").html("密码不能为空!");$(".passwordinfo").css({"color":"red","font-family":"KaiTi","font-size":"16px"});}else if($(this).val().length < 6){$(".passwordinfo").html("密码至少为6位!");$(".passwordinfo").css({"color":"red","font-family":"KaiTi","font-size":"16px"});}else{$(".passwordinfo").html("输入正确");$(".passwordinfo").css({"color":"green","font-family":"KaiTi","font-size":"16px"});ok2 = true;}});//输入不合法的情况下,获取焦点时清空错误输入$('input[id="username"]').focus(function(){if(!ok1){$('input[id="username"]').val("");}});$('input[id="password"]').focus(function(){if(!ok2){$('input[id="password"]').val("");}});//点击进行用户名后台验证,通过验证后实现页面跳转$(".submit-button button").click(function(){username=$("#username").val();password=$("#password").val();if(ok1 && ok2){//普通方式$.ajax({url:"/Login/ValidUser",type:"POST",dataType:"json",data:{username:"+username+",password:"+password+"},success:function(){window.location.href="menu.html";},error:function(){window.location.href="menu.html";}});//deferred模式// $.ajax("/Login/ValidUser",// {type:"post"},// {dataType:"json"},// {data:{username:"+username+",password:"+password+"}} // ).done(function(){window.location.href="menu.html";})// .fail(function(){window.location.href="menu.html";})}return false;//抑制了浏览器的默认点击行为});});。
登陆界面代码
登陆界⾯代码1、设计思想添加窗⼝界⾯,想i⾯添加⼀系列组件。
输⼊账号密码和验证码后,如果验证码正确,进⾏注册,否则注册失败。
注册成功后,验证码⾃动刷新,并将注册的帐号和密码保存。
注册失败后,验证码刷新,从新注册。
⽽后进⾏登录,输⼊帐号密码和验证码,当三个都输⼊对的时候,登录成功,否则登录失败,刷新验证码重新登录。
当点击刷新验证码后,验证码⾃动刷新。
2、流程图3、源程序代码package java作业;import java.awt.FlowLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.Random;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JTextField;class chuang extends JFrame implements ActionListener{private JTextField txt1;private JTextField txt2;private String base = "abcdefghijklmnopqrstuvwxyz0123456789";private String zifu;private JLabel haha;private JTextField txt3;private JButton d;private JButton dl;private JButton zc;private String zhanghao;private String mima;private String yanzheng;private StringBuffer sb;chuang(){setBounds(800,400,300,250);setVisible(true);setTitle("界⾯");setDefaultCloseOperation(EXIT_ON_CLOSE);setLayout(null);JLabel zh=new JLabel("帐号:");zh.setBounds(20,15,50,25);add(zh);JLabel mm=new JLabel("密码:");mm.setBounds(20,50,50,25);add(mm);JLabel en=new JLabel("点击按钮后,放⼤窗⼝刷新验证码");en.setBounds(20,150,200,25);add(en);Random random = new Random();sb = new StringBuffer();for (int i = 0; i < 4; i++){int number = random.nextInt(base.length());sb.append(base.charAt(number));}haha=new JLabel(sb.toString()+":");haha.setBounds(20,85,50,25);add(haha);txt1 = new JTextField(20);txt1.setBounds(65,15,150,25);add(txt1);txt1.setText("请输⼊帐号");txt2 = new JTextField(20);txt2.setBounds(65,50,150,25);add(txt2);txt2.setText("请输⼊密码");txt3 = new JTextField(20);txt3.setBounds(65,85,100,25);add(txt3);txt3.setText("请输⼊验证码");d=new JButton("刷新验证码");d.addActionListener(this);d.setBounds(170,85,100,24);add(d);dl=new JButton("登录");dl.addActionListener(this);dl.setBounds(35,120,75,24);add(dl);zc=new JButton("注册");zc.addActionListener(this);zc.setBounds(120,120,75,24);add(zc);validate();}public void actionPerformed(ActionEvent e){if(e.getSource()==d){remove(haha);Random random = new Random();sb = new StringBuffer();for (int i = 0; i < 4; i++){int number = random.nextInt(base.length());sb.append(base.charAt(number));}haha=new JLabel(sb.toString()+":");haha.setBounds(20,85,50,25);add(haha);validate();}else if(e.getSource()==dl){yanzheng=txt3.getText();if(yanzheng.equals(sb.toString())&&txt1.getText().equals(zhanghao)&&txt2.getText().equals(mima)) {JFrame ha=new JFrame("登录界⾯");ha.setBounds(880,460,150,100);ha.setVisible(true);JLabel hao=new JLabel("登录成功!");ha.add(hao);validate();}else{JFrame ha=new JFrame("登录界⾯"); ha.setBounds(880,460,150,100);ha.setVisible(true);JLabel hao=new JLabel("登录失败!"); ha.add(hao);validate();}}else if(e.getSource()==zc){yanzheng=txt3.getText();zhanghao=txt1.getText();mima=txt2.getText();if(yanzheng.equals(sb.toString())){JFrame ha=new JFrame("注册界⾯"); ha.setBounds(880,460,150,100);ha.setVisible(true);JLabel hao=new JLabel("注册成功!"); ha.add(hao);validate();}else{JFrame ha=new JFrame("注册界⾯"); ha.setBounds(880,460,150,100);ha.setVisible(true);JLabel hao=new JLabel("注册失败!"); ha.add(hao);validate();}remove(haha);Random random = new Random();sb = new StringBuffer();for (int i = 0; i < 4; i++){int number = random.nextInt(base.length()); sb.append(base.charAt(number));}haha=new JLabel(sb.toString()+":"); haha.setBounds(20,85,50,25);add(haha);validate();}}public void shuzi(){Random random = new Random(); StringBuffer sb = new StringBuffer();for (int i = 0; i < 4; i++){int number = random.nextInt(base.length()); sb.append(base.charAt(number));}System.out.println(sb.toString());}}public class suiji {public static void main(String args[]){new chuang();}}4、结果截图。
登录界面代码
<br />
<asp:Label ID="lbHint" runat="server" ForeColor="#FF3300"></asp:Label>
<br />
<br />
<span class="style2">登录信息:</span><asp:Panel ID="Panel1" runat="server"
BackColor="#FFFF99" BorderColor="#FFCC99" BorderStyle="Solid" Height="27px"
请从上面的菜单选择你的操作!<br />
<br />
<asp:Panel ID="Panel1" runat="server" Height="137px" Width="338px"
BackColor="#FFFF99">
<head id="Head1" runat="server">
<title>查看用户信息</title>
<style type="text/css">
.style1
图书馆管理系统登陆界面【范本模板】
1、程序代码package window;import data.BaseDao;import java.awt.AWTEvent;import java。
awt。
Container;import java。
awt。
Font;import java。
awt.GridLayout;import java。
awt.event.ActionEvent;import java。
awt.event。
ActionListener;import java.awt.event.KeyAdapter;import java.awt.event.KeyEvent;import java。
sql.ResultSet;import javax.swing。
*;import javax。
swing.plaf.FontUIResource;import util。
GlobalVar;/***类Login用于显示登录界面,要求系统用户输入正确的用户名和密码。
**@author raymond*/public class Login extends JFrame {private JLabel lb_user;private JTextField tf_user;private JLabel lb_pass;private JPasswordField pf_pass;private JButton btn_ok;private JButton btn_cancel;private int num = 0;//用来记录登陆不成功的次数public Login() {UIUtil。
setUIFont(new FontUIResource("宋体", Font.BOLD, 15));initComponents();}// 初始化组件private void initComponents(){lb_user = new JLabel();tf_user = new JTextField();//用户名输入文本框lb_pass = new JLabel();pf_pass = new JPasswordField();//密码输入文本框btn_ok = new JButton();//确认按钮btn_cancel = new JButton();//取消按钮setTitle("用户登录界面");setResizable(false);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);Container contentPane = getContentPane();contentPane。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
JPanel p4=new JPanel();
p5=new JPanel(){
protected void paintChildren(Graphics g) {
g.drawImage(img,0,0,this);
power="adminstrator";
}
else if((f1.getText()).equals("snake")&&(f2.getText()).equals("123456"))
{
{
if((f1.getText()).equals("admin")&&(f2.getText()).equals("123"))
{
JOptionPane.showMessageDialog(null, "登录成功!用户权限是adimistrator");
JOptionPane.showMessageDialog(null, "登录成功!登录成功!用户权限是user");
power="adminstrator";
}
else JOptionPane.showMessageDialog(null, "登录失败,请重新登录!");
super.paintChildren(g);
}
};
f1=new JTextField(15);
f2=new JPasswordField(15);
b1=new JButton("登录");
p3.add(l2);
p3.add(f2);
p3.setBackground(Color.ORANGE);
p3.setBorder(new MatteBorder(0,0,0,0,Color.BLACK));
p4.add(b1);
p4.add(b2);
p4.setBorder(new MatteBorder(-3,-3,-3,-3,Color.CYAN));
b2=new JButton("重置");
p1.setBackground(Color.orange);
p2.add(l1);
p2.add(f1);
p2.setBorder(new MatteBorder(0,0,0,0,Color.BLACK));
p2.setBackground(Color.ORANGE);
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
public class LoginIn extends JFrame{
JTextField f1;
}
}
class ReWrite implements ActionListener{
public void actionPerformed(ActionEvent e)
{
f1.setText("");
f2.setText("");
f1.requestFocus();
p4.setBackground(Color.ORANGE);
p5.setLayout(new FlowLayout(FlowLayout.CENTER,20,20));
p5.add(p2);
p5.add(p3);
p5.add(p4);
cp.add(p5,BorderLayout.CENTER);
b1.addActionListener(new Enter());
b2.addActionListener(new ReWrite());
addWindowListener(new winClose());
}
public static void main(String[] args) {
JTextField f2;
JButton b1;
JButton b2;
String power;//表示权限
String imgePath = "e:/workspace/GUI/14.gif";
JPanel p5;
Image img = Toolkit.getDefaultToolkit().createImage(imgePath);
LoginIn log=new LoginIn();
log.setTitle("系统登录");
log.setSize(360,250);
log.setVisible(true);
}
class Enter implements ActionListener{
public void actionPerformed(ActionEvent e)
LoginIn(){
Container cp=getContentPane();
Label l1=new Label("用户:");
Label l2=new Label("密码:");
JPanel p1=new JPanel();
JPanel p2=new JPanel();
} ቤተ መጻሕፍቲ ባይዱ
}
class winClose extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
(e.getWindow()).dispose();
System.exit(0);
}
}
}