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

📄 stuinfo.java

📁 运用java编写图书馆管理系统
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.StringTokenizer;

import javax.swing.*;

public class StuInfo extends JFrame{
	StuInfo(){
		//读入学生学号
		try{
		FileReader fr = new FileReader("deng.txt");
		BufferedReader br = new BufferedReader(fr);
		while ((r = br.readLine())!= null) {
			StringTokenizer sto = new StringTokenizer(r);
			r_name = sto.nextToken();
		}
		}catch(IOException ie){
			System.err.println("error:" + ie.getMessage());
		}
		//读入学生信息		
		try{
			FileReader fr = new FileReader(r_name+".txt");
			BufferedReader br = new BufferedReader(fr);			
			r=br.readLine();
			info[0]=r;
			r=br.readLine();
			info[1]=r;
			r=br.readLine();
			info[2]=r;
			r=br.readLine();
			info[3]=r;
			}catch(IOException ie){
				System.err.println("error:" + ie.getMessage());
			}
			//显示学生信息
			b_totalinfo=Box.createHorizontalBox();
			b_info=Box.createVerticalBox();
			for (int i=0;i<4;i++){
				lb_info[i]=new JLabel();
			    lb_info[i].setText(info[i]);
			    b_info.add(lb_info[i]);	
			}		
			//添加照片
			try{
		     ImageIcon icon = new ImageIcon("pic//"+r_name+".jpg");
		     photo=new JLabel();
		     photo.setIcon(icon);
		     photo.setToolTipText("A photo of " + r_name.toLowerCase());
		     b_totalinfo.add(Box.createHorizontalStrut(35));
		     b_totalinfo.add(photo);
			}catch(Exception ie){
				System.err.println("error:" + ie.getMessage());
			}
			b_totalinfo.add(Box.createHorizontalStrut(35));
			b_totalinfo.add(b_info);
			//添加按钮
			bt_ok=new JButton("确认");
			add(b_totalinfo,BorderLayout.CENTER);
			add(bt_ok,BorderLayout.SOUTH);
			bt_ok.addActionListener(new ok_evt());
	}
	class ok_evt implements ActionListener{
		public void actionPerformed(ActionEvent evt) {
			setVisible(false);
		}
	}

	String r_name,r,information;
	private String []info={"","","",""};
	private JLabel []lb_info=new JLabel[4];
	private Box b_info,b_totalinfo,b_ok;
	private JLabel photo;
	private JButton bt_ok;

}


⌨️ 快捷键说明

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