⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pp2.java

📁 一个JAVA的学生管理系统,用的是GUI的图形用户界面.
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import java.util.*;





////////////这是开始的入口处!!!






public class pp2 extends JFrame {
	static pp2 a=null;
	JFrame f1=new JFrame("登录窗口");
	JTextField tf1=new JTextField("<请您输入hello 2007帐号>",10);
	JPasswordField tf2=new JPasswordField(10);
	JLabel l_2=new JLabel("提示:");
	String getloadid,getloadpassword;
	public static void main(String args[]){
	 	a=new pp2();
	 	a.Waring();
	}
	
	public pp2(){}//构造函数
	
	public void pp2(){
		getloadid=null;
		getloadpassword=null;
		Container cp=f1.getContentPane();
		JPanel pa=new JPanel();
		JPanel pa1=new JPanel(),pa2=new JPanel(),pa3=new JPanel();
		JPanel pa3_1=new JPanel(new FlowLayout(FlowLayout.LEFT)),pa3_2=new JPanel(new GridLayout(1,6,5,1));
		pa.setLayout(new GridLayout(3,1));
		pa1.setLayout(new FlowLayout(FlowLayout.CENTER));
		pa2.setLayout(new GridLayout(2,2,10,10));pa2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.blue,3)));
		pa3.setLayout(new GridLayout(2,1));
		
		ImageIcon hello2007 = new ImageIcon("hello2007.jpg");
		JLabel icon=new JLabel(hello2007);icon.setToolTipText("这张照片是从网上下载的,不是本人做的");	
		JLabel l_0=new JLabel("              user:");
		JLabel l_1=new JLabel("          password:");
		JButton bt_0=new JButton("登录");bt_0.setToolTipText("点击登录,进入功能窗口");
		JButton bt_1=new JButton("退出");bt_1.setToolTipText("点击退出登录");
		JButton bt_2=new JButton("注册");bt_2.setToolTipText("若您还没有注册,请先注册");
	
		pa1.add(icon);
		pa2.add(l_0);
		pa2.add(tf1);
		pa2.add(l_1);
		pa2.add(tf2);
		pa3_1.add(l_2,FlowLayout.LEFT);
		pa3_2.add(new JLabel(""));
		pa3_2.add(new JLabel(""));
		pa3_2.add(new JLabel(""));
		pa3_2.add(bt_0);
		bt_0.addActionListener(new Load());
		pa3_2.add(bt_1);
		bt_1.addActionListener(new Exit());
		pa3_2.add(bt_2);
		bt_2.addActionListener(new AddUser());
		pa3.add(pa3_2);pa3.add(pa3_1);
		pa.add(pa1);pa.add(pa2);pa.add(pa3);
		cp.add(pa);
		f1.addWindowListener(new WinLis());
		f1.pack();
		f1.setVisible(true);
	}
	void Waring(){
		if(JOptionPane.OK_OPTION==JOptionPane.showConfirmDialog(f1,"严重警告:该程序源代码不得进行复制!\n不得利用任何方式进行转载!!!\n遵守程序员道德规范!","严重警告",JOptionPane.OK_CANCEL_OPTION,JOptionPane.WARNING_MESSAGE))
		this.pp2();
		else {JOptionPane.showMessageDialog(f1,null,"欢迎下次光临",JOptionPane.PLAIN_MESSAGE,new ImageIcon("byebye.jpg"));System.exit(0);}
	}
	String Getloadid(){
		getloadid=tf1.getText();
		return getloadid;
	}
	String Getloadpassword(){
		getloadpassword=String.copyValueOf(tf2.getPassword());
		return getloadpassword;
	}
	String Getloadtime(){
		Calendar now=Calendar.getInstance();
		int year,month,date,hour,minute,second;
		year=now.get(Calendar.YEAR);
		month=now.get(Calendar.MONTH)+1;
		date=now.get(Calendar.DATE);
		hour=now.get(Calendar.HOUR_OF_DAY);
		minute=now.get(Calendar.MINUTE);
		second=now.get(Calendar.SECOND);
		String loadtime=String.valueOf(year)+"/"+String.valueOf(month)+"/"+String.valueOf(date)+"/"+String.valueOf(hour)+"/"+String.valueOf(minute)+"/"+String.valueOf(second);
		return loadtime;
	}
	
	private class Load implements ActionListener{
		
		lau a=null;
		public void actionPerformed(ActionEvent load){
			if(load.getActionCommand().equals("登录")){
				int i=0;
				String id=pp2.a.Getloadid();
				String password=pp2.a.Getloadpassword();
				String checkpassword=null;
				System.out.println("landed success!");
				UserSql b=new UserSql();
				Record record=new Record();
				try{
					checkpassword=b.Check2(id);
				}catch(Exception e){
					l_2.setText("提示:取得登录密码失败!");
				}
				try{
					i=b.Check1(id);
				}catch(Exception e){
					l_2.setText("提示:取得登录姓名失败!");
				}
				
				if(i==1){
					if(password.equals(checkpassword)){
						try{
							
							try{record.LoadRecord(pp2.a.Getloadtime(),pp2.a.Getloadid());}catch(Exception e){System.out.println("记录登录信息失败!");}
							a=new lau();
							a.lau();
							f1.dispose();
						}catch(Exception g){l_2.setText("打开功能窗口失败!");}
					}else l_2.setText("提示:登录失败!密码错误!");
				}
				else if(i==0) l_2.setText("提示:登录失败!该用户不存在,请您注册!");

			}
		}
	}
	
	private class Exit implements ActionListener{
		public void actionPerformed(ActionEvent exit){
			if(exit.getActionCommand().equals("退出")){
				int i=JOptionPane.showConfirmDialog(f1,"您确定要退出吗?","退出系统",JOptionPane.OK_CANCEL_OPTION,JOptionPane.INFORMATION_MESSAGE);
				if(i==0){
					JOptionPane.showMessageDialog(f1,null,"欢迎下次光临",JOptionPane.PLAIN_MESSAGE,new ImageIcon("byebye.jpg"));
					System.exit(0);
				}
				if(i==1 || i==-1){
					pp2 b=new pp2();
					b.pp2();
					a.dispose();
				}
			}
		}
	}
	private class AddUser implements ActionListener{
		Xieyi a=null;
		public void actionPerformed(ActionEvent add){
			if(add.getActionCommand().equals("注册")){
				try{
					f1.dispose();
					a=new Xieyi();
					a.Xieyi();
				}catch(Exception a){
					l_2.setText("提示:打开协议窗口失败!");
				}
			}
		}
	}
	private class WinLis extends WindowAdapter{
		public void windowClosing(WindowEvent we){
			System.exit(0);
		}
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -