Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
GradeSystemPanel.java
Package: 简单的学生信息管理系统.rar [view]
Upload User: jt0027
Upload Date: 2011-09-11
Package Size: 3k
Code Size: 8k
Category:
Education soft system
Development Platform:
WINDOWS
- /**
- * <p>Title:Student Grade System</p>
- * <p>Discrition:</p>
- * <p>Copyright: li168feng@yahoo.com.cn Copyright (c) 2003.1.3</p>
- * <p>Company:</p>
- *@autor lifeng
- *@version 1.0
- */
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- class GradeSystemPanel extends JPanel
- {
- private JLabel Title;//show the title
- private JPanel LayPanel;//Layout the title pane
- private JLabel NamLabel;//show name message
- private JTextField NamText;//input name text field
- private JLabel NumLabel;//show number message
- private JTextField NumText;//input number text field
- private JLabel GradLabel;//show grade message
- private JTextField GradText;//input grade text field
- private JTextArea ShowArea;//show the message area
- private JTextArea ResuArea;//show the result area
- private JPanel BtnPanel;//layout the button pane
- private JButton AddBtn;//add button
- private JButton DelBtn;//delete button
- private JButton SeaBtn;//search button
- private JButton ChangBtn;//change button
- private JButton CouBtn;//count the average and total grade button
- private JScrollPane ShowScrollPane;//a scroll pane on ShowArea
- private JScrollPane ResuScrollPane;//a scroll pane on ResuArea
- private int num = 0;//count the student number
- private String[][] StudMess= new String[10][10];//a temp array of student
- public GradeSystemPanel()
- {
- setLayout(new BorderLayout());
- //new a label for show the title
- Title = new JLabel("成绩系统",JLabel.CENTER);
- add(Title,BorderLayout.NORTH);
- //new a panel for lay out the name and number and grade
- LayPanel = new JPanel(new GridLayout(4,2));
- //new a label for show the name
- NamLabel = new JLabel("姓名");
- LayPanel.add(NamLabel);
- //new a text field for input the name
- NamText = new JTextField("",10);
- LayPanel.add(NamText);
- //new a label for show the number of student
- NumLabel = new JLabel("学号");
- LayPanel.add(NumLabel);
- //new a text field for input the number of student
- NumText = new JTextField("",10);
- LayPanel.add(NumText);
- //new a label of show the grade of student
- GradLabel = new JLabel("成绩");
- LayPanel.add(GradLabel);
- //new a text field for input the grade of student
- GradText = new JTextField("",10);
- LayPanel.add(GradText);
- //new a text area for show the all student message
- ShowArea = new JTextArea();
- //new a scroll pane on the ShowArea
- ShowScrollPane = new JScrollPane(ShowArea);
- ShowArea.append(" name number graden");
- LayPanel.add(ShowScrollPane);
- //new a text area for show the search and average result
- ResuArea = new JTextArea();
- //new a scroll pane on ResuArea
- ResuScrollPane = new JScrollPane(ResuArea);
- LayPanel.add(ResuScrollPane);
- //add the panel
- add(LayPanel,BorderLayout.CENTER);
- //new a panel for lay out the button
- BtnPanel = new JPanel();
- //new a add button
- AddBtn = new JButton("添加");
- BtnPanel.add(AddBtn);
- //new a delete button
- DelBtn = new JButton("删除");
- BtnPanel.add(DelBtn);
- //new a search button
- SeaBtn = new JButton("查询");
- BtnPanel.add(SeaBtn);
- //new a change the student message button
- ChangBtn = new JButton("修改");
- BtnPanel.add(ChangBtn);
- //new a cout the all student average button
- CouBtn = new JButton("算平均分");
- BtnPanel.add(CouBtn);
- add(BtnPanel,BorderLayout.SOUTH);
- //add the button action
- //first is addition button action event
- AddBtn.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent event)
- {
- //add message function
- AddMessage();
- NamText.setText("");//clear the NameText
- NumText.setText("");//clear the NumText
- GradText.setText("");//clear the GradText
- }
- });
- //second is searching button action event
- SeaBtn.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent event)
- {
- //clear the ResuArea
- ResuArea.setText("");
- //Searching message function
- SearchMess();
- }
- });
- //third is deleting button action event
- DelBtn.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent event)
- {
- //deleting message funtion
- DeletMess();
- }
- });
- //four is changeing button action event
- ChangBtn.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent evet)
- {
- //changing message function
- ChangeMess();
- }
- });
- //last is count the average button action event
- CouBtn.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent event)
- {
- //clear the ResuArea
- ResuArea.setText("");
- //Counting the average and total grade function
- CountAver();
- }
- });
- }
- //add the student message function
- public void AddMessage()
- {
- String StrMess = new String();
- //add the student message
- if(!NamText.getText().equals("")&&!NumText.getText().equals("")&&!GradText.getText().equals(""))
- {
- //add the message
- StrMess = NamText.getText()+" "+NumText.getText()+" "+GradText.getText()+"n";
- StudMess[num][0] = NamText.getText();//add the name in StudMess
- StudMess[num][1] = NumText.getText();//add the number in StudMess
- StudMess[num][2] = GradText.getText();//add the grade in StudMess
- num++;
- }
- //show the message in show area
- ShowArea.append(StrMess);
- }
- //search the student message function
- public void SearchMess()
- {
- //input searching name in this box
- String SeaNam = JOptionPane.showInputDialog("Input you want to search name?");
- String StrMess = new String();
- //search the searching name
- for(int i=0;i<num;i++)
- {
- if(SeaNam.equalsIgnoreCase(StudMess[i][0]))
- StrMess = StudMess[i][0]+" "+StudMess[i][1]+" "+StudMess[i][2]+"n";
- }
- //show the searching name message in Result area
- ResuArea.append(StrMess);
- }
- //delete the student message function
- public void DeletMess()
- {
- //input deleting name in this box
- String DeletNam = JOptionPane.showInputDialog("Input you want to delete name?");
- String StrMess = new String();
- //search the deleting name
- for (int i=0;i<num;i++)
- {
- if(DeletNam.equalsIgnoreCase(StudMess[i][0]))
- {
- for(int k=i;k<num-1;k++)
- {
- //move last number to prefer
- StudMess[i][0]=StudMess[i+1][0];
- StudMess[i][1]=StudMess[i+1][1];
- StudMess[i][2]=StudMess[i+1][2];
- StudMess[i][3]=StudMess[i+1][3];
- }
- //the number delete 1
- num--;
- }
- }
- //clear the Show area
- ShowArea.setText("");
- //update new date
- ShowArea.append(" name number graden");
- for(int i=0;i<num;i++)
- {
- StrMess = StudMess[i][0]+" "+StudMess[i][1]+" "+StudMess[i][2]+"n";
- //show the new message
- ShowArea.append(StrMess);
- }
- }
- //change the student message function
- public void ChangeMess()
- {
- //input the changing name
- String ChangNam = JOptionPane.showInputDialog("Input you want to change naem?");
- for(int i=0;i<num;i++)
- {
- if(ChangNam.equalsIgnoreCase(StudMess[i][0]))
- {
- //input the new name
- String NewNam = JOptionPane.showInputDialog("Input the new name?");
- StudMess[i][0] = NewNam;
- //input the new number
- String NewNum = JOptionPane.showInputDialog("Input the new number?");
- StudMess[i][1] = NewNum;
- //input the new grade
- String NewGrad = JOptionPane.showInputDialog("Input the new grade?");
- StudMess[i][2] = NewGrad;
- }
- }
- String StrMess = new String();
- //clear the Show area
- ShowArea.setText("");
- //update new date
- ShowArea.append(" name number graden");
- for(int i=0;i<num;i++)
- {
- StrMess = StudMess[i][0]+" "+StudMess[i][1]+" "+StudMess[i][2]+"n";
- //show the new message
- ShowArea.append(StrMess);
- }
- }
- //count the student message function
- public void CountAver()
- {
- //init the total grade;
- int total = 0;
- //count the total grade
- for(int i=0;i<num;i++)
- {
- total +=Integer.parseInt(StudMess[i][2]);
- }
- //show the student number
- ResuArea.append("student total number is :"+num+"n");
- //show the all students' total grade
- ResuArea.append("total grade is :"+total+"n");
- //show the all students' average grade
- ResuArea.append("average grade is :"+total/num+"n");
- }
- }