Java写图书管理系统(三、用户功能页面)

164 阅读2分钟

上篇介绍了注册页面,下面我们就要进入正题了---------功能页面

我将功能页面分为:用户功能页面     and        管理员功能页面

ps:使用者是用户还是管理员无需区别登录,直接由系统根据登录账户判定~~~~~~~~~

 

 

 

下面先来看用户功能页面吧:

主页面长这样,每个按钮功能均已实现,标题为当前用户名~~~~~~~

查看个人资料:

修改本人资料:

修改后的资料:

查看由管理员上传的图书库:

代码实现:

package Library;

import java.awt.Frame;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 * 用户功能选项
 * @author hwt1070359898
 *
 */
public class UserFunction extends Frame implements ActionListener{
	//定义各个控件
	private JButton btLookSelf=new JButton("查看个人资料");
	private JButton btModify=new JButton("修改个人资料");
	private JButton btLookBooks=new JButton("查看书库信息");
	private JButton btExit=new JButton("退出系统");

	public UserFunction(){
		
		super("用户:"+User.num);//串口标题
		this.setLayout(null);//设置为手工设置各个组件的位置和大小
		
		btLookSelf.setBounds(new Rectangle(50,80,300,50));//修改个人资料
		btModify.setBounds(new Rectangle(50,150,300,50));//修改个人资料
		btLookBooks.setBounds(new Rectangle(50,220,300,50));//查看书库信息
		btExit.setBounds(new Rectangle(50,290,300,50));//退出系统
		
		btLookSelf.addActionListener(this);
		btModify.addActionListener(this);
		btLookBooks.addActionListener(this);
		btExit.addActionListener(this);
		
		this.add(btLookSelf);
		this.add(btModify);
		this.add(btLookBooks);
		this.add(btExit);
		
		this.setSize(400,370);
		
		GUIUtil.toCenter(this);//使窗口居中
		this.setVisible(true);//可视化
		this.setResizable(false);//关闭放大窗口
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置错误关闭操作
		
		//用于关闭窗体事件
		this.addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent e){
				dispose();
			}
		});
	}
	
	private void setDefaultCloseOperation(int exitOnClose) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		if(e.getSource()==btLookSelf) {
			String message="您的详细资料为:\n";
			
            message+="学号:"+User.num+"\n";
            message+="姓名:"+User.name+"\n";
            message+="用户名:"+User.username+"\n";
            message+="性别:"+User.sex+"\n";
            message+="年龄:"+User.age+"\n";
            message+="班级:"+User.clas+"\n";
            
            JOptionPane.showMessageDialog(this,message);
        }else if(e.getSource()==btModify) {
			new ModifyDialog("固定学号:"+User.num);
			this.dispose();
        }
        else if(e.getSource()==btLookBooks) {
           this.dispose();
        	new ShowBook(); 
        }
        else if(e.getSource()==btExit){
            JOptionPane.showMessageDialog(this,"谢谢光临,欢迎下次继续使用本系统!");
            System.exit(0);
        }
	}
}

用户功能就是如此,下篇看管理员功能`````````````````

文章中有任何问题,都欢迎大家来骚扰哟,博主希望和大家一起进步~~~~~~