Java课程设计 - 学生通讯录管理系统(4)

2019-08-31 09:36

}

return sname;

public void setSname(String sname) { }

public String getPhonumber() { }

public void setPhonumber(String phonumber) { }

public String getSex() { }

public void setSex(String sex) { }

public String getDept() { }

public void setDept(String dept) { }

public Information(int snum, String sname, String phonumber, String sex,String dept) {

super();

this.snum = snum; this.sname = sname;

this.phonumber = phonumber; this.sex = sex; this.dept = dept; }

}

this.dept = dept; return dept; this.sex = sex; return sex;

this.phonumber = phonumber; return phonumber; this.sname = sname;

4.ui包中的类:

(1) LoginUI类:此类为登陆界面,在这个界面上,设置有两

个按钮,学生按钮,教师按钮。给这两个按钮注册事件addActionListener,分别在内部类TeacherLoginActionListene和StudentLoginActionListener中的默认方法actionPerformed()中创建TeacherLoginUI类和StudentLoginUI类的对象,即打开教师登陆界面和学生登录界面,并将原登陆界面关闭。 LoginUI类源代码:

package ui; import java.awt.*; import java.awt.event.*; import javax.swing.*;

public class LoginUI extends JFrame {

JLabel l1;

JButton bt1, bt2; Container cp; public LoginUI() {

l1 = new JLabel(\请选择用户类型\); bt1 = new JButton(\教师\); bt2 = new JButton(\学生\); JPanel p1 = new JPanel(); p1.setLayout(null);

l1.setBounds(150, 150, 120, 40); p1.add(l1);

bt1.setBounds(120, 230, 80, 30); p1.add(bt1);

bt2.setBounds(220, 230, 80, 30); p1.add(bt2);

bt1.addActionListener(new

TeacherLoginActionListener());//注册事件 bt2.addActionListener(new StudentLoginActionListener());//注册事件 cp = getContentPane();

this.setBounds(200, 200, p1.getHeight(), cp.add(p1);

this.setTitle(\用户登录界面\); this.setSize(400, 400); this.setVisible(true);

p1.getHeight());

}

this.addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent e) { }

System.exit(0);

});

class TeacherLoginActionListener implements }

public void actionPerformed(ActionEvent e){ }

new TeacherLoginUI(); dispose();

ActionListener{

class StudentLoginActionListener implements ActionListener{

public void actionPerformed(ActionEvent e){ }

}

public static void main(String[] args) { } }

new LoginUI();

new StudentLoginUI(); dispose();

执行截图如下:

(2)StudentLoginUI类:此类为学生登陆界面,在这个界面

上有两个文本框,分别输入学生姓名和登录密码,还有四个按钮,查询、注册、修改和退出。输入后,从两个文本框中获取用户输入的内容,点击“查询”按钮时,调用StudentDao类中的student()方法验证是否存在该用户。若存在,则创建StudentInformationUI类的对象,即打开学生信息界面,显示此登陆学生的信息,若不存在,则提示密码错误。单击“注册”按钮,调用StudentDao类中的student()方法验证是否存在该用户。若存在,则创建ZhuceStudentUI类的对象,即打开学生注册界面。单击“修改”按钮,调用StudentDao类中的student()方法验证是否存在该用户。若存在,则创建xiugaiStudentUI类的对象,即打开修改学生密码界面。

StudentLoginUI类源代码:

package ui;

import java.awt.*; import java.awt.event.*; import javax.swing.*; import Dao.StudentDao;

public class StudentLoginUI extends JFrame{

JLabel l1, l2; JTextField t1; JPasswordField t2; JButton bt1, bt2; Container cp;

public static String st1; public String st2; public StudentLoginUI(){

l1 = new JLabel(\学生姓名\); l2 = new JLabel(\密码\); t1 = new JTextField(12); t2 = new JPasswordField(12); bt1 = new JButton(\查询\); bt2 = new JButton(\退出\);

JPanel p1 = new JPanel(); p1.setLayout(null);

l1.setBounds(150, 150, 80, 40);

p1.add(l1);

t1.setBounds(250, 150, 80, 30); p1.add(t1);

l2.setBounds(150, 190, 80, 40); p1.add(l2);

t2.setBounds(250, 190, 80, 30); p1.add(t2);

bt1.setBounds(150, 280,70, 30); p1.add(bt1);

bt2.setBounds(240, 280, 70, 30); p1.add(bt2);

bt1.addActionListener(new

LoginActionListener());//注册事件 bt2.addActionListener(new

bt2.addActionListener(new

ExitActionListener());//注册事件 cp = getContentPane();

}

class LoginActionListener implements ActionListener {

public void actionPerformed(ActionEvent e) {

st1 = t1.getText(); st2 = t2.getText(); StudentDao oneStudentDao = new StudentDao(); boolean isSuccess = oneStudentDao.student(st1, this.setBounds(200, 200, p1.getHeight(), cp.add(p1);

this.setTitle(\学生登录界面\); this.setSize(450, 450); this.setVisible(true);

this.addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent e) { }

System.exit(0);

p1.getHeight());

});


Java课程设计 - 学生通讯录管理系统(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:躲避球策划

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: