This example for you to share the Java implementation of the student management system of the specific code for your reference, the specific content as follows
Package bookdemo_1;
Import javax.swing.*;
Import java.awt.*;
Import java.awt.event.*;
public class Test {public static void main (string[] args) {Studentsys stusys=new Studentsys ("Student management System");
Stusys.initwin ();
} class Studentsys extends jframe{private JPanel P1,p2,p3,combop;
Private JTabbedPane tab;
Private Container Container;
Private JButton b1,b2;
Private Listener Listener;
Private Label Namelabel;
Private Label Gradelabel;
Private Label ShowLabel;
Private JTextField Textname;
Private JTextField Textgrade;
Private TextArea Showgradearea;
* * * Find * * * * private Label Searchlabel;
Private JTextField SearchText;
Private JButton sbut;
Private JTextField Resulttext;
Private string[] name;
Private string[] grade;
/* * Sort */private TextArea Showtextarea;
Private JButton sortbut;
private int countnum=0;
Private JButton clearbut; Public Studentsys (String str) {SUPER (str);
This.name=new string[100];
This.grade=new string[100];
Listener = new Listener ();
tab = new JTabbedPane (jtabbedpane.top);
Container container = This.getlayeredpane ();
Object panel Combop = new JPanel ();
P1 = new JPanel ();
P2 = new JPanel ();
P3 = new JPanel ();
B1 =new JButton ("confirm add");
B2 =new JButton ("recall add");
Namelabel =new Label ("name");
Gradelabel =new Label ("achievement"); Showlabel=new Label (the current record is zero!)
");
Textname =new JTextField (15);
Textgrade =new JTextField (15);
Showgradearea=new TextArea ();
* * * * */searchlabel=new Label ("Please enter Name:");
Searchtext=new JTextField (15);
Sbut=new JButton ("Confirm Lookup");
Resulttext=new JTextField (15);
/* * Sort */showtextarea=new TextArea ();
Sortbut=new JButton ("ranking of grades");
Clearbut=new JButton ("Empty data"); public void Initwin () {this.setbounds (300, 300, 500, 400);
This.addwindowlistener (New Windowadapter () {public void windowclosing (WindowEvent e) {SUPER.WINDOWCL
Osing (e);
System.exit (0);
}});
Layoutwin ();
This.setvisible (TRUE);
private void Layoutwin () {Tab.add (P1, "score input");
Tab.add (P2, "score query");
Tab.add (P3, "grade ranking");
Combop.add (New JLabel ("Student Information Management system");
Container.setlayout (New BorderLayout ());
Container.add (Combop,borderlayout.north);
Container.add (Tab,borderlayout.center);
Container con1=new Container ();
Con1.setlayout (New FlowLayout ());
Con1.add (Namelabel);
Con1.add (Textname);
Con1.add (Gradelabel);
Con1.add (Textgrade);
P1.add (Con1,borderlayout.north);
P1.add (Con1);
P1.add (Showgradearea);
Container con2=new Container ();
Con2.setlayout (New FlowLayout ());
Con2.add (B1);
Con2.add (B2);
Con2.add (ShowLabel);
P1.add (Con2);
B1.addactionlistener (listener); B2.addActionListener (listener);
* * Find layout * */Container con3=new Container ();
Con3.setlayout (New FlowLayout ());
Con3.add (Searchlabel);
Con3.add (SearchText);
Con3.add (sbut);
P2.add (Con3,borderlayout.north);
Sbut.addactionlistener (listener);
P2.add (Resulttext);
* * * Sort layout * */P3.add (Showtextarea);
P3.add (sortbut);
P3.add (clearbut);
Sortbut.addactionlistener (listener);
Clearbut.addactionlistener (listener); * * * Java internal class implementation ActionListener Interface * * */class Listener implements actionlistener{@Override Public v OID actionperformed (ActionEvent e) {if (E.getsource () ==b1) {if (Textname.gettext (). Equal S ("")) | | (Textgrade.gettext (). Equals ("")) {Showlabel.settext (name, result cannot be empty)!
");
} else{Name[countnum]=textname.gettext ();
Grade[countnum]=textgrade.gettext ();
countnum++;String area= "Add success, currently has" +countnum+ "record";
Showlabel.settext (area);
Sortmess (FALSE);
Textname.settext ("");
Textgrade.settext ("");
} if (E.getsource () ==b2) {if (countnum>0) {countnum--;
String area= "withdrawn successfully, currently has" +countnum+ "record";
Showlabel.settext (area);
Sortmess (FALSE); } if (E.getsource () ==sbut) {if (!searchtext.gettext (). Equals ()) {searchmess (searchtext
. GetText ());
} if (E.getsource () ==sortbut) {sortmess (true); } if (E.getsource () ==clearbut) {if (!showtextarea.gettext (). Equals (")) {Showtextarea.settext (" ")
; }} public void Sortmess (Boolean sign) {//TODO auto-generated method stub if (sign {for (int i=0;i<countnum;i++) {for (int j=i+1;j<countnum;j++) {if (integer.parse)Int (Grade[i]) <integer.parseint (Grade[j])) {String s1,s2;
S1=name[i];
S2=grade[i];
NAME[I]=NAME[J];
GRADE[I]=GRADE[J];
NAME[J]=S1;
GRADE[J]=S2; }else{if (!showgradearea.gettext (). Equals ("")) {Showgradeare
A.settext ("");
} for (int i=0;i<countnum;i++) {String content= "name:" +name[i]+ "\ T" + "score" +grade[i];
if (sign) showtextarea.append (content+ "\ n");
else Showgradearea.append (content+ "\ n"); The public void searchmess (String n) {//TODO auto-generated a stub for (int i=
0;i<countnum;i++) {if (Name[i].equals (n)) {String content= "name:" +name[i]+ "," + "result" +grade[i];
Resulttext.settext (content);
Return }} resulttext.settext ("The student was not found! ");}}}
The above is the entire content of this article, I hope to learn Java program to help you.