前言:
該學生資訊管理系統項目是使用Java swing開發,可實作基礎資料維護、使用者登入、學生資訊清單檢視、修改、删除和模糊查找以及退出登出等功能、界面設計比較簡單易學、适合作為Java課設設計以及學習技術使用。引言
學生資訊管理系統是一個教育機關不可缺少的部分。 一個功能齊全、簡單易用的資訊管理系統不但能有效地減輕學校相關從業人員的工作負擔, 它的内容對于學校的決策者和管理者來說都至關重要。 是以學生資訊管理系統應該能夠為用 戶提供充足的資訊和快捷的查詢手段。 但一直以來人們使用傳統人工的方式管理 檔案檔案、統計和查詢資料,這種管理方式存在着許多缺點,如:效率低、保密 性差、人工的大量浪費; 随着科學技術的不斷提高, 計算機科學日漸成熟,其強大的功能已為人們深刻認識, 它已進入人類社會的各個領域并發揮着越來越重要的作用。 作為計算機應用的一部分, 使用計算機對學校的各類資訊進行管理, 具有手工管理無法比拟的優點。也是一個機關科學化、正規化管理,與世界接軌的重要條件。
主要技術和工具:
eclipse+JDK1.8+swing+文本存儲
功能截圖:
使用者登入注冊:
使用者輸入賬号密碼進行登入、成功登入檢視首頁和學生資訊。
首頁學生資料清單:
學生資訊添加:
錄入學生相關資訊完成學生添加操作
學生資訊修改:
選中需要修改的資料、在輸入框或選擇框完修改操作。
學生資訊删除:
登出退出:
登出退出執行頁面關閉操作。
關鍵代碼:
使用者登入:
public class Main {
//設定表的題頭
public static String[] t_head = {"學号","姓名","性别","年齡","學院","位址"};
//定義學生清單
public static String[][] s_list = new String[20][6];
//給學生清單初始化值
static
{
s_list[0]= new String[]{"16103301", "小明", "男","19","計算機學院","河南"};
s_list[1]= new String[]{"16103302", "小華", "女","20","藝術學院","河北"};
s_list[2]= new String[]{"16103303", "小松", "男","21","海洋學院","天津"};
s_list[3]= new String[]{"16103304", "小美", "女","22","藝術學院","海南"};
s_list[4]= new String[]{"16103305", "小南", "男","20","經管學院","甘肅"};
s_list[5]= new String[]{"16103306", "小傑", "男","20","電信學院","浙江"};
s_list[6]= new String[]{"16103307", "小花", "女","20","計算機學院","山東"};
}
//定義大框的名字
public static TopJFrame top;
//public static void main(String[] args) {
//top = new TopJFrame("學生資訊管理系統");
public static void main(String[] args) throws IOException {
top = new TopJFrame("學生資訊管理系統 奧斯卡有根粉紅香腸");
File file=new File("students.txt");
if(!(file.exists())){
file.createNewFile();
}
new Main();
FileWriter out = new FileWriter(file);
for(int i=0;i<20;i++){
if(s_list[i][0] != null)
for(int j=0;j<6;j++){
out.write(s_list[i][j]+"\t" + "\t");
}
out.write("\r\n");
}
out.close();
}
public void Filewriter(ArrayList<StudentBean> students,String file) throws IOException{//寫入檔案方法
FileWriter fw=new FileWriter(file);
BufferedWriter bw=new BufferedWriter(fw);
Iterator<StudentBean> it=students.iterator();
while(it.hasNext()){
StudentBean std=(StudentBean)it.next();
bw.write(std.getS_id());
bw.newLine();
bw.write(std.getS_name());
bw.newLine();
bw.write(std.getS_age());
bw.newLine();
bw.write(std.getS_sex());
bw.newLine();
bw.write(std.getS_address());
bw.newLine();
}
bw.flush();
bw.close();
}
public void Filereader(ArrayList<StudentBean> students,String file) throws IOException{//讀取檔案方法
FileReader fr=new FileReader(file);
BufferedReader br=new BufferedReader(fr);
String str=null;
while((str=br.readLine())!=null){
StudentBean std=new StudentBean();
std.setS_id(str);
str=br.readLine();
std.setS_name(str);
str=br.readLine();
std.setS_age(str);
str=br.readLine();
std.setS_sex(str);
str=br.readLine();
std.setS_address(str);
students.add(std);
}
br.close();
}
}
添加學生資訊:
public class InsertListener implements ActionListener{
private JDialog err,masg;
public void actionPerformed(ActionEvent e) {
String id = InsertDialog.t_id.getText();
String name = InsertDialog.t_name.getText();
String sex = InsertDialog.cb_sex.getSelectedItem().toString();
String age = InsertDialog.t_age.getText();
String ac = InsertDialog.cb_ac.getSelectedItem().toString();
String sp = InsertDialog.t_address.getText();
// System.out.println(id+","+name+","+sex+","+age+","+ac);
if(id.equals("")||name.equals("")||sex.equals("")||age.equals("")||ac.equals("")||sp.equals("")){
InsertDialog.err.setText("各項資訊都不能為空!");
}else{
InsertDialog.err.setText("");
ManagerJpanel.t_m.setValueAt(id, ManagerJpanel.row,0);
ManagerJpanel.t_m.setValueAt(name, ManagerJpanel.row,1);
ManagerJpanel.t_m.setValueAt(sex, ManagerJpanel.row,2);
ManagerJpanel.t_m.setValueAt(age, ManagerJpanel.row,3);
ManagerJpanel.t_m.setValueAt(ac, ManagerJpanel.row,4);
ManagerJpanel.t_m.setValueAt(sp, ManagerJpanel.row,5);
masg = new JDialog();
masg.setAlwaysOnTop(true);
masg.setLayout(null);
JLabel jl = new JLabel("新增成功!");
jl.setBounds(110, 20, 150, 30);
masg.add(jl);
masg.setSize(300, 130);
masg.setLocationRelativeTo(null);
masg.setVisible(true);
masg.repaint();
Thread tr = new Thread(){
public void run() {
try {
this.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
masg.dispose();
TableListener.jd_i.dispose();
ManagerJpanel.row++;
};
};
tr.start();
}
}
}
備注:項目來于網絡、作者整理優化測試、若有侵權聯系作者删除
總結:
經過近期對 java 相關知識面向對象程式設計、Java swing等的掌握和學習,讓我更加了解到 java 學習的重要性。在開發這個學生資訊管理系統,我完成多個實驗以及測功能試,在這個階段的學習開發中,我從認識到熟悉,而後到能夠自主運用。通過對 java swing知識以及資料庫的設計相關的了解,我發現它确實有很多友善之處,它集抽象性、封裝性、繼承性和多态性于一體,實作了代碼重用和代碼擴充,提高了軟體開發的效率。對于我們這個專業來說學好 java 語言是很重要的,是以在開發這個項目的過程中我都盡力了解 java 程式設計思想、掌握基本技巧,盡量學到最多的知識。 我學習程式設計的基本目的就是培養描述實際問題的程式化解決方案的關鍵技能,總體來說 java 面向對象程式設計是一門實踐性比較強的語言。完整源碼下載下傳位址
打卡JavaSwing項目更新 6 / 100篇