已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
这是我以前写的系统登录框的loginpackage java1;import java.awt.*;import java.awt.event.*;import java.sql.*;import java.util.*;import javax.swing.*;import javax.swing.event.*;import java.awt.Rectangle;import java.awt.Font;public class login extends JFrame public login() try jbInit(); catch (Exception ex) ex.printStackTrace(); public static void main(String args) login frm=new login(); frm.setBounds(300,200,300,260); frm.setVisible(true); private void jbInit() throws Exception this.getContentPane().setLayout(null); jLabel1.setForeground(Color.red); jLabel1.setText(用户名); jLabel1.setBounds(new Rectangle(25, 72, 68, 29); jButton2.setBounds(new Rectangle(142, 159, 81, 30); jButton2.setText(取消); jButton2.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) jButton2_actionPerformed(e); ); jButton1.setBounds(new Rectangle(38, 159, 81, 29); jButton1.setText(确定); jButton1.addActionListener(new ActionListener() public void actionPerformed(ActionEvent e) jButton1_actionPerformed(e); ); jTextField1.setBounds(new Rectangle(109, 79, 136, 23); jPasswordField1.setBounds(new Rectangle(109, 115, 136, 23); this.getContentPane().add(jLabel1); jLabel3.setFont(new java.awt.Font(隶书, Font.PLAIN, 24); jLabel3.setText(学 生 考 试 系 统); jLabel3.setBounds(new Rectangle(22, 15, 268, 47); this.getContentPane().add(jTextField1); this.getContentPane().add(jLabel2); this.getContentPane().add(jButton2); this.getContentPane().add(jButton1); this.getContentPane().add(jLabel3); this.getContentPane().add(jPasswordField1); jLabel2.setForeground(Color.red); jLabel2.setText(密码); jLabel2.setBounds(new Rectangle(26, 112, 68, 29); JLabel jLabel1 = new JLabel(); JLabel jLabel2 = new JLabel(); JTextField jTextField1 = new JTextField(); JButton jButton1 = new JButton(); JButton jButton2 = new JButton(); JLabel jLabel3 = new JLabel(); JPasswordField jPasswordField1 = new JPasswordField(); main2 wo=new main2(); int sum; /判断权限的方法 public void success() try ResultSet rs1; String s1=select * from 管理权限 where name=+jTextField1.getText()+ and password=+jPasswordField1.getText()+; rs1=sqlcx.Rs_jiluji(s1); rs1.first(); sum=Integer.parseInt(String)(rs1.getString(3); System.out.println(sum); very(); catch(Exception c)System.out.println(success error); /根据权限设置窗口 public void very() if (sum=1) JOptionPane.showOptionDialog(this, 您现在是以教师权限登陆, 登陆信息 , JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, null, null); else JOptionPane.showOptionDialog(this, 你现在是以学生权限登陆, 登陆信息 , JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, null, null); wo.jButton2.setVisible(false); wo.jButton3.setVisible(false); wo.jButton4.setVisible(false); wo.jButton5.setVisible(false); wo.jButton6.setVisible(false); wo.jButton7.setVisible(false); wo.jButton8.setVisible(false); wo.jMenu2.setVisible(false); wo.jMenu3.setVisible(false); wo.jMenu4.setVisible(false); public void jButton1_actionPerformed(ActionEvent e) /判断用户名是否为空 if (jTextField1.getText().length() = 0) JOptionPane.showOptionDialog(this, 用户名不能为空, 错误信息 , JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, null, null); /判断密码是否为空 else if (jPasswordField1.getText().length()=0) JOptionPane.showOptionDialog(this,密码不能为空, 错误信息 , JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, null, null); else try ResultSet rs;/声明记录集 String sql=select * from 管理权限 where name=+jTextField1.getText()+; rs = sqlcx.Rs_jiluji(sql); if (rs.next() if(jPasswordField1.getText().equals(rs.getString(2) success(); wo.setBounds(60,40,700,600); wo.setVisible(true); this.dispose(); else JOptionPane.showOptionDialog(this,密码错误, 错误信息 , JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, null, null); else JOptionPane.showOptionDialog(this,没有所要找的用户名, 错误信息 , JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, null, null); catch(Except
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- GBT 6730.49-2017 铁矿石 钾含量的测定 火焰原子吸收光谱法专题研究报告
- 智能硬件装调员达标模拟考核试卷含答案
- 实验动物繁殖员岗前实操掌握考核试卷含答案
- 制卤工创新应用竞赛考核试卷含答案
- 陶瓷注浆成型工创新意识竞赛考核试卷含答案
- 渔业观察员岗前理论综合考核试卷含答案
- 宠物驯导师岗前安全检查考核试卷含答案
- 裂解汽油加氢装置操作工诚信品质竞赛考核试卷含答案
- 胶合板胶合工岗位安全技术规程
- 粗钨酸钠溶液制备工安全应急测试考核试卷含答案
- 2025山西医药学院招聘人事代理人员7人笔试考试备考题库及答案解析
- 寺庙修缮工程协议书
- YY/T 1994-2025采用机器人技术的血管介入手术控制系统
- 物流行业仓储管理岗位货物调度效率考核表
- 5.2 少年当自强 教案 2024-2025学年统编版道德与法治九年级下册
- 2025年第十一届《中金所杯全国大学生金融知识大赛》复赛题库附答案
- 酿造酒工艺与品鉴培训
- 2025年及未来5年中国卫生杀虫剂行业市场供需格局及行业前景展望报告
- 2025江西宜春市丰城高级技工学校招聘30人考试笔试备考试题及答案解析
- 2026-2031年中国山慈菇行业市场发展现状及投资前景预测报告
- 2025年国学经典知识竞赛题库及答案
评论
0/150
提交评论