java简单学生信息系统源码
更新时间:2024-03-09 00:30:01 阅读量: 综合文库 文档下载
简单学生信息系统的设计与实现
代码如下:(添加部分用灰色底纹标出) /*--------- Delete ------------*/ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; import java.sql.*; import java.util.*;
public class Delete extends JPanel implements ActionListener{
HashMap
ButtonGroup group=null; FileInputStream inOne=null; ObjectInputStream inTwo=null; FileOutputStream outOne=null; ObjectOutputStream outTwo=null;
File systemFile=null; public Delete(File file){ systemFile=file;
学号=new JTextField(10); 删除=new JButton(\删除\ 学号.addActionListener(this); 删除.addActionListener(this); 姓名=new JTextField(10); 姓名.setEditable(false);
专业=new JTextField(10); 专业.setEditable(false); 年级=new JTextField(10); 年级.setEditable(false); 出生=new JTextField(10); 出生.setEditable(false);
男=new JRadioButton(\男\ 女=new JRadioButton(\女\ group=new ButtonGroup(); group.add(男); group.add(女);
Box box1=Box.createHorizontalBox(); box1.add(new JLabel(\输入要删除的学号:\ box1.add(学号); box1.add(删除);
Box box2=Box.createHorizontalBox(); box2.add(new JLabel(\姓名:\ box2.add(姓名);
Box box3=Box.createHorizontalBox(); box3.add(new JLabel(\性别:\ box3.add(男); box3.add(女);
Box box4=Box.createHorizontalBox(); box4.add(new JLabel(\专业:\ box4.add(专业);
Box box5=Box.createHorizontalBox(); box5.add(new JLabel(\年级:\ box5.add(年级);
Box box6=Box.createHorizontalBox(); box6.add(new JLabel(\出生:\
box6.add(出生);
Box boxH=Box.createVerticalBox(); boxH.add(box1); boxH.add(box2); boxH.add(box3); boxH.add(box4); boxH.add(box5); boxH.add(box6);
boxH.add(Box.createVerticalGlue()); JPanel pCenter=new JPanel();
pCenter.add(boxH);//真正的添加得在JPanel中才会显示 setLayout(new BorderLayout()); add(pCenter,BorderLayout.CENTER); validate(); }
public void actionPerformed(ActionEvent e){ if(e.getSource()==删除||e.getSource()==学号){ String number=\ number=学号.getText(); Connection con; Statement sql; ResultSet rs; String mes;
if(number.length()>0){ try {
Class.forName(\ }
catch(ClassNotFoundException e1) {
System.out.println(e1);
} try {
con=DriverManager.getConnection(\ sql=con.createStatement();
rs=sql.executeQuery(\ while(rs.next())
{ String num=rs.getString(\ String name=rs.getString(\ String zhuanye=rs.getString(\ String sex=rs.getString(\ String borth=rs.getString(\ String nianji=rs.getString(\ 姓名.setText(name); 专业.setText(zhuanye); 年级.setText(nianji); 出生.setText(borth); if(sex.equals(\男\ 男.setSelected(true); else
女.setSelected(true);
String m=\确定要删除该学号及全部信息吗?\
int ok=JOptionPane.showConfirmDialog(this,m,\确认\
JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE); if(ok==JOptionPane.YES_OPTION) {
rs=sql.executeQuery(\ con.close();
} }
}
catch(SQLException e2){ System.out.println(e2); } } } } }
/*-----------InputStudent---------------------*/ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*;
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.*;
import javax.swing.filechooser.*;
public class InputStudent extends JPanel implements ActionListener{ Student 学生=null; StudentPicture pic;
HashMap
JComboBox 专业; JRadioButton 男,女; ButtonGroup group=null; JButton 录入,重置;
FileInputStream inOne=null; ObjectInputStream inTwo=null; FileOutputStream outOne=null; ObjectOutputStream outTwo=null; File systemFile,imagePic; public InputStudent(File file){ systemFile=file;
pic=new StudentPicture(); 学号=new JTextField(5); 姓名=new JTextField(5); 专业=new JComboBox();
try{
FileReader inOne=new FileReader(\专业.txt\ BufferedReader inTwo= new BufferedReader(inOne); String s=null; int i=0;
while((s=inTwo.readLine())!=null) 专业.addItem(s); inOne.close(); inTwo.close(); }
catch(IOException exp){ 专业.addItem(\数学\
专业.addItem(\计算机科学与技术\ }
年级=new JTextField(5); 出生=new JTextField(5); 选择照片=new JButton(\选择\ group=new ButtonGroup(); 男=new JRadioButton(\男\ 女=new JRadioButton(\女\ group.add(男); group.add(女);
录入=new JButton(\录入\ 重置=new JButton(\重置\ 录入.addActionListener(this); 选择照片.addActionListener(this); 重置.addActionListener(this);
Box box1=Box.createHorizontalBox(); box1.add(new JLabel(\学号:\ box1.add(学号);
Box box2=Box.createHorizontalBox(); box2.add(new JLabel(\姓名:\ box2.add(姓名);
Box box3=Box.createHorizontalBox(); box3.add(new JLabel(\性别:\ box3.add(男); box3.add(女);
Box box4=Box.createHorizontalBox(); box4.add(new JLabel(\专业:\ box4.add(专业);
Box box5=Box.createHorizontalBox(); box5.add(new JLabel(\年级:\ box5.add(年级);
Box box6=Box.createHorizontalBox();
box6.add(new JLabel(\出生:\ box6.add(出生);
Box boxH=Box.createVerticalBox(); boxH.add(box1); boxH.add(box2); boxH.add(box3); boxH.add(box4); boxH.add(box5); boxH.add(box6);
boxH.add(Box.createVerticalGlue()); JPanel picPanel=new JPanel();
picPanel.setBackground(Color.green); picPanel.add(new JLabel(\选择照片:\ picPanel.add(选择照片);
JPanel putButton=new JPanel(); putButton.add(录入);
putButton.add(重置); JPanel messPanel=new JPanel(); messPanel.add(boxH);
messPanel.setBackground(Color.cyan); putButton.setBackground(Color.red); setLayout(new BorderLayout()); JSplitPane splitV=
new JSplitPane(JSplitPane.VERTICAL_SPLIT,picPanel,pic);
JSplitPane splitH=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,messPanel,splitV); add(splitH,BorderLayout.CENTER); add(putButton,BorderLayout.SOUTH); validate(); }
public void actionPerformed(ActionEvent e) {
if(e.getSource()==录入) {
String number=\学号已存在!\ number=学号.getText(); Connection con; Statement sql; ResultSet rs_in,rs; String mes;
if(number.length()>0) { try {
Class.forName(\
}
catch(ClassNotFoundException e1) {
System.out.println(e1); } try
{ con=DriverManager.getConnection(\ sql=con.createStatement();
rs=sql.executeQuery(\ if(rs.next() )
{ String warning=\该学号已存在,请重输!\
JOptionPane.showMessageDialog(this,warning,\警告\ } else {
int num=Integer.parseInt(学号.getText()); String name=String.valueOf(姓名.getText()); String discipling=(String)专业.getSelectedItem(); String grade=年级.getText(); String borth=出生.getText(); String sex=null; if(男.isSelected()) sex=男.getText(); else
sex=女.getText();
String m=\基本信息将被录入!\
int ok=JOptionPane.showConfirmDialog(this,m,\确认\
JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE); rs_in=sql.executeQuery(\ values('\ }
catch(SQLException e2) {
mes=e2.toString(); } } else{
String warning=\必须要输入学号!\
JOptionPane.showMessageDialog(this,warning,\警告\ }
}
}
else if(e.getSource()==重置){ clearMess(); } }
public void clearMess(){ 学号.setText(null); 姓名.setText(null); 年级.setText(null); 出生.setText(null); 选择照片.setText(\选择\ imagePic=null; pic.setImage(imagePic); pic.repaint(); } }
/*---------------------- Inquest ---*/ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*;
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.*;
public class Inquest extends JDialog implements ActionListener{ StudentPicture pic; PrintJob print; Graphics g=null;
HashMap
JButton 查询,打印文本及照片,打印文本,打印照片; ButtonGroup group=null; FileInputStream inOne=null; ObjectInputStream inTwo=null; File systemFile=null; JPanel messPanel; Student stu;
public Inquest(File file){ setTitle(\查询对话框\ setModal(false);
systemFile=file;
pic=new StudentPicture(); 学号=new JTextField(6); 查询=new JButton(\查询\ 学号.addActionListener(this); 查询.addActionListener(this);
打印文本及照片=new JButton(\打印文本及照片\ 打印文本=new JButton(\打印文本\ 打印照片=new JButton(\打印照片\ 打印文本及照片.addActionListener(this); 打印文本.addActionListener(this); 打印照片.addActionListener(this); 打印文本及照片.setEnabled(false); 打印文本.setEnabled(false); 打印照片.setEnabled(false); 姓名=new JTextField(5); 姓名.setEditable(false); 专业=new JTextField(5); 专业.setEditable(false); 年级=new JTextField(5); 年级.setEditable(false); 出生=new JTextField(5); 出生.setEditable(false);
男=new JRadioButton(\男\ 女=new JRadioButton(\女\ group=new ButtonGroup(); group.add(男); group.add(女);
Box box1=Box.createHorizontalBox();
box1.add(new JLabel(\学号:\ box1.add(学号); box1.add(查询);
Box box2=Box.createHorizontalBox(); box2.add(new JLabel(\姓名:\ box2.add(姓名);
Box box3=Box.createHorizontalBox();
box3.add(new JLabel(\性别:\ box3.add(男); box3.add(女);
Box box4=Box.createHorizontalBox();
box4.add(new JLabel(\专业:\ box4.add(专业);
Box box5=Box.createHorizontalBox();
box5.add(new JLabel(\年级:\
box5.add(年级);
Box box6=Box.createHorizontalBox(); box6.add(new JLabel(\出生:\ box6.add(出生);
Box boxH=Box.createVerticalBox(); boxH.add(box1); boxH.add(box2); boxH.add(box3); boxH.add(box4); boxH.add(box5); boxH.add(box6);
boxH.add(Box.createVerticalGlue()); messPanel=new JPanel(); messPanel.add(boxH);
JSplitPane splitH=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,messPanel,pic); add(splitH,BorderLayout.CENTER); JPanel pSouth=new JPanel(); pSouth.add(打印文本及照片); pSouth.add(打印文本); pSouth.add(打印照片);
add(pSouth,BorderLayout.SOUTH); validate(); setVisible(false); setSize(360,230);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){ setVisible(false); }}); }
public void actionPerformed(ActionEvent e) {
if(e.getSource()==查询||e.getSource()==学号){ String number=\ number=学号.getText(); Connection con; Statement sql; ResultSet rs; String mes;
if(number.length()>0) { try {
Class.forName(\ }
catch(ClassNotFoundException e1)
{
System.out.println(e1); } try {
con=DriverManager.getConnection(\ sql=con.createStatement();
rs=sql.executeQuery(\ while(rs.next())
{ String num=rs.getString(\ String name=rs.getString(\ String zhuanye=rs.getString(\ String sex=rs.getString(\ String borth=rs.getString(\ String nianji=rs.getString(\ 姓名.setText(name); 专业.setText(zhuanye); 年级.setText(nianji); 出生.setText(borth); if(sex.equals(\男\ 男.setSelected(true); else
女.setSelected(true); } }
catch(SQLException e2) {
System.out.println(e2); } } else {
打印文本及照片.setEnabled(false); 打印文本.setEnabled(false); 打印照片.setEnabled(false); String warning=\必须要输入学号!\
JOptionPane.showMessageDialog(this,warning,\警告\
JOptionPane.WARNING_MESSAGE); } } }
public void clearMess(){
学号.setText(null); 姓名.setText(null); 年级.setText(null); 出生.setText(null); 专业.setText(null); pic.setImage(null); pic.repaint(); } }
/*---------------------- ManagerWindow -------*/ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*;
import java.util.HashMap;
public class ManagerWindow extends JFrame implements ActionListener{ InputStudent 基本信息录入; ModifySituation 基本信息修改; Inquest 基本信息查询与打印; Delete 基本信息删除; JMenuBar bar; JMenu fileMenu;
JMenuItem 录入,修改,查询与打印,删除,欢迎界面;
HashMap
public ManagerWindow(){
录入=new JMenuItem(\录入学生基本信息\ 修改=new JMenuItem(\修改学生基本信息\
查询与打印=new JMenuItem(\查询与打印学生基本信息\
删除=new JMenuItem(\删除学生基本信息\ 欢迎界面=new JMenuItem(\欢迎界面\ bar=new JMenuBar();
fileMenu=new JMenu(\菜单选项\ fileMenu.add(录入); fileMenu.add(修改); fileMenu.add(查询与打印); fileMenu.add(删除); fileMenu.add(欢迎界面); bar.add(fileMenu); setJMenuBar(bar);
label=new JLabel(\学籍管理系统\ label.setIcon(new ImageIcon(\ label.setFont(new Font(\隶书\
label.setHorizontalTextPosition(SwingConstants.CENTER); label.setForeground(Color.red);
基本信息=new HashMap
FileOutputStream out=new FileOutputStream(file);
ObjectOutputStream objectOut=new ObjectOutputStream(out);
objectOut.writeObject(基本信息); objectOut.close(); out.close(); }
catch(IOException e){} }
基本信息录入=new InputStudent(file); 基本信息修改=new ModifySituation(file); 基本信息查询与打印=new Inquest(file); 基本信息删除=new Delete(file); pCenter.add(\欢迎界面\ pCenter.add(\录入界面\基本信息录入); pCenter.add(\修改界面\基本信息修改); pCenter.add(\删除界面\基本信息删除); add(pCenter,BorderLayout.CENTER); validate(); setVisible(true);
setBounds(100,50,550,400);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
int n=JOptionPane.showConfirmDialog(null,\确认退出吗?\确认对话框\ JOptionPane.YES_NO_OPTION ); if(n==JOptionPane.YES_OPTION) System.exit(0); }}); validate(); }
public void actionPerformed(ActionEvent e){ if(e.getSource()==录入){
基本信息录入.clearMess(); card.show(pCenter,\录入界面\ }
else if(e.getSource()==修改){ 基本信息修改.clearMess(); card.show(pCenter,\修改界面\ }
else if(e.getSource()==查询与打印){ 基本信息查询与打印.clearMess();
基本信息查询与打印.setLocation(getBounds().x+getBounds().width,getBounds().y); 基本信息查询与打印.setVisible(true); }
else if(e.getSource()==删除) card.show(pCenter,\删除界面\ else if(e.getSource()==欢迎界面) card.show(pCenter,\欢迎界面\ }
public static void main(String args[]){ new ManagerWindow(); } }
/*--------- ModifySituation --------------------*/ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*;
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException;
import java.sql.Statement; import java.util.*;
import javax.swing.filechooser.*;
public class ModifySituation extends JPanel implements ActionListener{ StudentPicture pic;
HashMap
JButton 选择照片; JRadioButton 男,女; ButtonGroup group=null; JButton 开始修改,录入修改,重置; FileInputStream inOne=null; ObjectInputStream inTwo=null; FileOutputStream outOne=null; ObjectOutputStream outTwo=null; File systemFile,imagePic; JComboBox oldMess; Student stu=null;
public ModifySituation(File file){ systemFile=file;
pic=new StudentPicture(); 学号=new JTextField(6);
姓名=new JTextField(6); 专业=new JComboBox(); try{
FileReader inOne=new FileReader(\专业.txt\ BufferedReader inTwo= new BufferedReader(inOne); String s=null; int i=0;
while((s=inTwo.readLine())!=null) 专业.addItem(s); inOne.close(); inTwo.close(); }
catch(IOException exp){ 专业.addItem(\数学\
专业.addItem(\计算机科学与技术\ }
年级=new JTextField(6); 出生=new JTextField(6); 选择照片=new JButton(\选择\ group=new ButtonGroup(); 男=new JRadioButton(\男\ 女=new JRadioButton(\女\ group.add(男); group.add(女);
oldMess=new JComboBox(); 开始修改=new JButton(\开始修改\ 录入修改=new JButton(\录入修改\ 录入修改.setEnabled(false); 选择照片.setEnabled(false); 重置=new JButton(\重置\ 学号.addActionListener(this); 开始修改.addActionListener(this); 录入修改.addActionListener(this); 重置.addActionListener(this); 选择照片.addActionListener(this);
Box box1=Box.createHorizontalBox();
box1.add(new JLabel(\输入要修改信息的学号:\
box1.add(学号); box1.add(开始修改);
Box box2=Box.createHorizontalBox(); box2.add(new JLabel(\新)姓名:\ box2.add(姓名);
Box box3=Box.createHorizontalBox(); box3.add(new JLabel(\新)性别:\ box3.add(男); box3.add(女);
Box box4=Box.createHorizontalBox(); box4.add(new JLabel(\新)专业:\ box4.add(专业);
Box box5=Box.createHorizontalBox(); box5.add(new JLabel(\新)年级:\ box5.add(年级);
Box box6=Box.createHorizontalBox(); box6.add(new JLabel(\新)出生:\ box6.add(出生);
Box box7=Box.createHorizontalBox(); box7.add(new JLabel(\学生已有的数据:\ box7.add(oldMess);
Box boxH=Box.createVerticalBox(); boxH.add(box1); boxH.add(box2); boxH.add(box3); boxH.add(box4); boxH.add(box5); boxH.add(box6); boxH.add(box7);
boxH.add(Box.createVerticalGlue());
JPanel picPanel=new JPanel();
picPanel.setBackground(Color.green); picPanel.add(new JLabel(\选择照片:\ picPanel.add(选择照片); JPanel putButton=new JPanel(); putButton.setBackground(Color.yellow); putButton.add(录入修改); putButton.add(重置); JPanel messPanel=new JPanel(); messPanel.setBackground(Color.pink); messPanel.add(boxH);
setLayout(new BorderLayout()); JSplitPane splitV=
new JSplitPane(JSplitPane.VERTICAL_SPLIT,picPanel,pic);
JSplitPane splitH=new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,messPanel,splitV); add(splitH,BorderLayout.CENTER); add(putButton,BorderLayout.SOUTH); validate(); }
public void actionPerformed(ActionEvent e){ if(e.getSource()==开始修改||e.getSource()==学号){ oldMess.removeAllItems(); String number=\ imagePic=null; stu=null; Connection con; Statement sql; ResultSet rs; String mes;
number=学号.getText();
if(number.length()>0){ /* try {
Class.forName(\ }
catch(ClassNotFoundException e1) {
System.out.println(e1); } try{
con=DriverManager.getConnection(\
sql=con.createStatement();
rs=sql.executeQuery(\ if(!rs.next() )
{ String warning=\该学号不存在,请重输!\
JOptionPane.showMessageDialog(this,warning,\警告\ }
else
{ while(rs.next())
{录入修改.setEnabled(true);
选择照片.setEnabled(true); String num=rs.getString(\ String name=rs.getString(\ String zhuanye=rs.getString(\String sex=rs.getString(\ String borth=rs.getString(\ String nianji=rs.getString(\ 姓名.setText(name);
// 专业.setText(zhuanye); 年级.setText(nianji);
出生.setText(borth); if(sex.equals(\男\ 男.setSelected(true); else
女.setSelected(true); } } }
catch(SQLException e2) {
System.out.println(e2); } } }
else if(e.getSource()==重置){ clearMess();
录入修改.setEnabled(false); 选择照片.setEnabled(false); } }
public void clearMess() {
学号.setText(null); 姓名.setText(null); 年级.setText(null); 出生.setText(null);
oldMess.removeAllItems(); 选择照片.setText(\选择\ imagePic=null; pic.setImage(imagePic);
pic.repaint(); } }*/ try {
inOne=new FileInputStream(systemFile); inTwo=new ObjectInputStream(inOne);
基本信息表=(HashMap
catch(Exception ee){}
if(基本信息表.containsKey(number)){ 录入修改.setEnabled(true); 选择照片.setEnabled(true); stu=基本信息表.get(number);
oldMess.addItem(\姓名:\ oldMess.addItem(\专业:\ oldMess.addItem(\年级:\ oldMess.addItem(\出生日期:\ if(stu.getSex().equals(\男\ 男.setSelected(true); else
女.setSelected(true); imagePic=stu.getImagePic(); pic.setImage(imagePic); pic.repaint();
姓名.setText(stu.getName()); 年级.setText(stu.getGrade()); 出生.setText(stu.getBorth());
} else{
录入修改.setEnabled(false); 选择照片.setEnabled(false); String warning=\该学号不存在!\
JOptionPane.showMessageDialog(this,warning,\警告\
JOptionPane.WARNING_MESSAGE); clearMess(); } } else{
录入修改.setEnabled(false); 选择照片.setEnabled(false); String warning=\必须要输入学号!\
JOptionPane.showMessageDialog(this,warning,\警告\ clearMess(); } }
else if(e.getSource()==录入修改){ String number=\ number=学号.getText(); if(number.length()>0){ try {
inOne=new FileInputStream(systemFile); inTwo=new ObjectInputStream(inOne);
基本信息表=(HashMap
catch(Exception ee){}
if(基本信息表.containsKey(number)){
String question=\该生基本信息已存在,您想修改他(她)的基本信息吗?\ JOptionPane.showMessageDialog(this,question,\警告\
JOptionPane.QUESTION_MESSAGE); String m=\基本信息将被修改!\
int ok=JOptionPane.showConfirmDialog(this,m,\确认\
JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE); if(ok==JOptionPane.YES_OPTION){ String name=姓名.getText(); if(name.length()==0) name=stu.getName();
String discipling=(String)专业.getSelectedItem(); if(discipling==null) discipling=stu.getDisciping(); String grade=年级.getText(); if(grade.length()==0) grade=stu.getGrade(); String borth=出生.getText();
if(borth.length()==0) borth=stu.getBorth(); String sex=null; if(男.isSelected()) sex=男.getText(); else
sex=女.getText(); if(imagePic==null)
imagePic=stu.getImagePic(); Student 学生=new Student(); 学生.setNumber(number); 学生.setName(name);
学生.setDiscipling(discipling); 学生.setGrade(grade); 学生.setBorth(borth); 学生.setSex(sex);
学生.setImagePic(imagePic); try{
outOne=new FileOutputStream(systemFile); outTwo=new ObjectOutputStream(outOne); 基本信息表.put(number,学生); outTwo.writeObject(基本信息表);
outTwo.close(); outOne.close(); clearMess(); } catch(Exception ee){} 录入修改.setEnabled(false); 选择照片.setEnabled(false); }
else if(ok==JOptionPane.NO_OPTION){ 录入修改.setEnabled(true); 选择照片.setEnabled(true); } } else{
String warning=\该学号没有基本信息,不能修改!\ JOptionPane.showMessageDialog(this,warning,\警告\
JOptionPane.WARNING_MESSAGE); 录入修改.setEnabled(false); 选择照片.setEnabled(false); clearMess();
} } else{
String warning=\必须要输入学号!\
JOptionPane.showMessageDialog(this,warning,\警告\ 录入修改.setEnabled(false); clearMess();
录入修改.setEnabled(false); 选择照片.setEnabled(false); } }
else if(e.getSource()==选择照片){
JFileChooser chooser=new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter( \ chooser.setFileFilter(filter);
int state=chooser.showOpenDialog(null); File choiceFile=chooser.getSelectedFile();
if(choiceFile!=null&&state==JFileChooser.APPROVE_OPTION){ 选择照片.setText(choiceFile.getName()); imagePic=choiceFile; pic.setImage(imagePic); pic.repaint(); } }
else if(e.getSource()==重置){ clearMess();
录入修改.setEnabled(false); 选择照片.setEnabled(false);
} }
public void clearMess(){ 学号.setText(null); 姓名.setText(null); 年级.setText(null); 出生.setText(null);
oldMess.removeAllItems(); 选择照片.setText(\选择\ imagePic=null; pic.setImage(imagePic); pic.repaint(); } }
/*---------------------- Student ----------*/ import java.io.*;
public class Student implements Serializable{ String number,name,discipling,grade,borth,sex; File imagePic;
public void setNumber(String number){ this.number=number; }
public String getNumber(){ return number; }
public void setName(String name){ this.name=name; }
public String getName(){ return name;
}
public void setDiscipling(String discipling){ this.discipling=discipling; }
public String getDisciping(){ return discipling; }
public void setGrade(String grade){ this.grade=grade; }
public String getGrade(){ return grade; }
public void setBorth(String borth){ this.borth=borth; }
public String getBorth(){ return borth; }
public void setSex(String sex){ this.sex=sex; }
public String getSex(){ return sex; }
public void setImagePic(File image){ imagePic=image; }
public File getImagePic(){ return imagePic;
} }
/*---------------- StudentPicture -----*/ import javax.swing.*; import java.io.*; import java.awt.*;
public class StudentPicture extends JPanel{ File imageFile; Toolkit tool;
public StudentPicture(){ tool=getToolkit(); }
public void setImage(File imageFile){ this.imageFile=imageFile; repaint(); }
public void paintComponent(Graphics g){ super.paintComponent(g); int w=getBounds().width; int h=getBounds().height; if(imageFile!=null){
Image image=tool.getImage(imageFile.getAbsolutePath()); g.drawImage(image,0,0,w,h,this); } else
g.drawString(\没有选择照片图像\ } }
正在阅读:
java简单学生信息系统源码03-09
岳麓版历史必修同步训练:第三单元测试05-06
加气混凝土砌块施工方案-专用砂浆 -11-10
东大15秋学期《安全检测及仪表》在线作业1满分答案08-08
校外培训机构审批及管理办法【最新版】05-01
2018年重庆市中考真题化学02-22
傲慢与偏见婚姻观的开题报告 - 图文04-14
泥浆护壁回转钻孔灌注桩施工方案01-03
网络效应经济理论_文献回顾与评论06-12
- 多层物业服务方案
- (审判实务)习惯法与少数民族地区民间纠纷解决问题(孙 潋)
- 人教版新课标六年级下册语文全册教案
- 词语打卡
- photoshop实习报告
- 钢结构设计原理综合测试2
- 2014年期末练习题
- 高中数学中的逆向思维解题方法探讨
- 名师原创 全国通用2014-2015学年高二寒假作业 政治(一)Word版
- 北航《建筑结构检测鉴定与加固》在线作业三
- XX县卫生监督所工程建设项目可行性研究报告
- 小学四年级观察作文经典评语
- 浅谈110KV变电站电气一次设计-程泉焱(1)
- 安全员考试题库
- 国家电网公司变电运维管理规定(试行)
- 义务教育课程标准稿征求意见提纲
- 教学秘书面试技巧
- 钢结构工程施工组织设计
- 水利工程概论论文
- 09届九年级数学第四次模拟试卷
- 源码
- 简单
- 学生
- 系统
- 信息
- java
- 小学英语Dont worry教学设计
- Photoshop图像处理电大期末复习题2015剖析
- 东石镇塔头小学德育工作计划2009春季
- 沈阳工程学院校外实习报告 - 图文
- 基于四次样条的矩阵微分方程数值解
- 如何带领小组查经
- 2019年书法比赛活动总结
- 中小学英语交流研讨会发言材料
- §-6-定积分的应用习题与答案- 副本(转)
- 年产1700台低温真空泵项目可行性研究报告(目录) - 图文
- 最新2018201X年工会工作总结word版本(3页)
- 东大15年10月考试《管理文秘A卷(1)》考核作业满分答案
- 重组大客户服务部营销团队的构想
- 安全生产条件论证报告
- 102839 - 电力定额工程量计算规则06版(1)
- 第十三章 基因的转录、转录后
- 已审:二年级下语文期末测试题2015.5.20
- 用Excel表格实现机打支票
- 跨塘便道施工方案
- 填报志愿前必做的几件事