歡迎來到裝配圖網(wǎng)! | 幫助中心 裝配圖網(wǎng)zhuangpeitu.com!
裝配圖網(wǎng)
ImageVerifierCode 換一換
首頁 裝配圖網(wǎng) > 資源分類 > DOCX文檔下載  

Java學生課程設計源碼要點

  • 資源ID:25967568       資源大小:20.04KB        全文頁數(shù):15頁
  • 資源格式: DOCX        下載積分:0積分
快捷下載 游客一鍵下載
會員登錄下載
微信登錄下載
三方登錄下載: 微信開放平臺登錄 支付寶登錄   QQ登錄   微博登錄  
二維碼
微信掃一掃登錄
下載資源需要0積分
郵箱/手機:
溫馨提示:
用戶名和密碼都是您填寫的郵箱或者手機號,方便查詢和重復下載(系統(tǒng)自動生成)
支付說明:
本站最低充值0.01積分,下載本資源后余額將會存入您的賬戶,您可在我的個人中心查看。
驗證碼:   換一換

 
賬號:
密碼:
驗證碼:   換一換
  忘記密碼?
    
友情提示
2、PDF文件下載后,可能會被瀏覽器默認打開,此種情況可以點擊瀏覽器菜單,保存網(wǎng)頁到桌面,就可以正常下載了。
3、本站不支持迅雷下載,請使用電腦自帶的IE瀏覽器,或者360瀏覽器、谷歌瀏覽器下載即可。
4、本站資源下載后的文檔和圖紙-無水印,預覽文檔經(jīng)過壓縮,下載后原文更清晰。
5、試題試卷類文檔,如果標題沒有明確說明有答案則都視為沒有答案,請知曉。

Java學生課程設計源碼要點

package com.lb.view;import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Login extends JFrame private TextField f1;private TextField f2;private JButton b1;private JButton b2;private JButton b3;/登陸界面public Login()列布局Container cp=getContentPane();/ 容器 cp.setBackground(Color.cyan);cp.setLayout(new GridLayout(4,1);/Panel p1=new Panel();Panel p2=new Panel();Panel p3=new Panel();Panel p4=new Panel();f1=new TextField(15);f2=new TextField(15);f2.setEchoChar(*);/回顯字符為 *b1=new JButton(" 登錄");b2=new JButton("重置");b3=new JButton(" 退出");p1.add(new Label(" ");p2.add(new Label("用戶名"); p2.add(f1);p3.add(new Label("密 碼”);p3.add(f2);p4.add(b1);p4.add(b2);p4.add(b3);cp.add(p1);cp.add(p2);cp.add(p3);cp.add(p4);b1.addActionListener(new Enter();b2.addActionListener(new ReWrite();b3.addActionListener(new Close();任艷云")&&(f2.getText().equals("ren12")class Enter implements ActionListener public void actionPerformed(ActionEvent e) if(f1.getText().equals( XueSheng framel = new XueSheng();frame1.setBounds(200, 200, 400, 400);framel.setVisible(true);else JOptionPane.showMessageDialog(null,”用戶名或密碼錯誤,請重新登錄!");class ReWrite implements ActionListener public void actionPerformed(ActionEvent e) f1.setText("");f2.setText("");f1.requestFocus();class Close implements ActionListener public void actionPerformed(ActionEvent e) JButton bt=(JButton)e.getSource();if(bt=b3)System.exit(0);主函數(shù)程序開始public static void main(String口 args) Login log=new Login();log.setTitle("系統(tǒng)登錄");log.setBounds(200, 200, 300, 300);log.setBackground(Color.red);log.setVisible(true);/信息管理界面內(nèi)部類進行初始化和保存class XueSheng extends JFrame implements ActionListener private JButton cx, zj, tc, sc,xg,tj;public XueSheng() Container c = this.getContentPane();c.setLayout(new GridLayout(4, 1);c.setBackground(Color.cyan);c.setFont(new Font("true",Font.TRUETYPE_FONT,13);JPanel panel1 = new JPanel();panel1.setBackground(Color.cyan);JLabel label1 = new JLabel("歡迎登入成績管理主頁 ”,SwingConstants.CENTER);label1.setFont(new Font("true",Font.TRUETYPE_FONT,15);panel1.add(label1);JPanel panel2 = new JPanel();panel2.setBackground(Color.cyan);JPanel panel3 = new JPanel();panel3.setBackground(Color.cyan);JPanel panel4 = new JPanel();panel4.setBackground(Color.cyan);/添加按鈕cx = new JButton("查詢)panel2.add(cx);zj = new JButton("增加)panel2.add(zj);sc = new JButton(" 刪除"); panel3.add(sc);xg = new JButton("修改");panel3.add(xg);tc = new JButton(" 退出"); panel4.add(tc);c.add(panell);c.add(panel2);c.add(panel3);c.add(panel4);cx.addActionListener(this);zj.addActionListener(this);sc.addActionListener(this);xg.addActionListener(this);tc.addActionListener(this); this.setVisible(true);public void actionPerformed(ActionEvent e) if (e.getSource() = cx) Query f = new Query();if(e.getSource()=zj)Inseter f = new Inseter();if(e.getSource()=sc)Delete d = new Delete();if(e.getSource()=xg)Update x=new Update。;if(e.getSource()=tc) shutDown();private void shutDown() JOptionPane.showMessageDialog(null,” 信息已保存");this.dispose();插入源碼:package com.lb.view;import java.awt.Color;import java.awt.Container;import java.awt.FlowLayout;import java.awt.Font;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.FileNotFoundException;import java.io.IOException;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.SwingConstants;import com.lb.bean.Student;import com.lb.dao.DaoImpl;class Inseter extends JFrame implements ActionListener private JTextField STNOText, SNAMEText, MAText, CHIText, JAVAText;private JButton b1, b2, b3;private String STNO, SNAME,MAT, CHI, JAVA;private Student a;public Inseter() super("添加學生信息)Container c2 = this.getContentPane();c2.setLayout(new GridLayout(3, 1);c2.setBackground(Color.cyan);JPanel center = new JPanel();center.setLayout(new GridLayout(5, 4);center.setBackground(Color.cyan);JPanel low = new JPanel(new FlowLayout();low.setBackground(Color.cyan);JLabe11abel1 = new JLabel("添加學生信息",SwingConstants.CENTER);label1.setFont(new Font("TRUE", Font.TRUETYPE_FONT, 20);c2.add(label1);STNOText = new JTextField(20);30列文本框SNAMEText = new JTextField(20);CHIText = new JTextField(20);MAText = new JTextField(20);JAVAText = new JTextField(20);center.add(new JLabel(" ");添加標簽學號寫在標簽中間center.add(new JLabel(" 學號:",SwingConstants.CENTER);/center.add(STNOText);/添加文本框center.add(new JLabel(" ");center.add(new JLabel(" ");center.add(new JLabel(" 姓名:",SwingConstants.CENTER);center.add(SNAMEText);center.add(new JLabel(" ");center.add(new JLabel(" ");center.add(new JLabel(" 語文:",SwingConstants.CENTER);center.add(CHIText);center.add(new JLabel(" ");center.add(new JLabel(" ");center.add(new JLabel(" 數(shù)學:",SwingConstants.CENTER);center.add(MAText);center.add(new JLabel(" ");center.add(new JLabel(" ");center.add(new JLabel("java:", SwingConstants.CENTER);center.add(JAVAText);center.add(new JLabel(" ");c2.add(center);b1 = new JButton("添加");b2 = new JButton("清除");b3 = new JButton("退出");low.add(b1);low.add(b2);low.add(b3);c2.add(low);/添加監(jiān)聽b1.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);this.setBounds(200, 200, 600, 400);this.setVisible(true);this.setTitle(" 添加學生信息)public void actionPerformed(ActionEvent e) if (e.getSource() = b1) try inseter(); catch (FileNotFoundException e1) e1.printStackTrace(); catch (IOException e1) e1.printStackTrace(); if (e.getSource() = b2) clearForm(); if (e.getSource() = b3) this.dispose(); private void inseter() throws FileNotFoundException, IOException STNO = STNOText.getText();SNAME = SNAMEText.getText();CHI = CHIText.getText();MAT = MAText.getText();JAVA = JAVAText.getText();Student stu =new Student。;if (STNO.length() = 0 | SNAME.length() = 0 | MAT.length() = 0 | JAVA.length() = 0 | CHI.length() = 0)JOptionPane.showMessageDialog(this,”請?zhí)砑油耆畔?quot;); else Student a=new Student(SNAME,STNO, Integer.parseInt(CHI),Integer.parseInt(MAT),Integer.parseInt(JAVA); DaoImpl di = new DaoImpl();di.inseter(a);JOptionPane.showMessageDialog(this," 添加成功! !”); private void clearForm() STNOText.setText("");SNAMEText.setText("");MAText.setText("");CHIText.setText("");JAVAText.setText("");刪除源碼:package com.lb.view; import java.awt.Color;import java.awt.Container;import java.awt.Font;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTextArea;import javax.swing.JTextField;import javax.swing.SwingConstants;import com.lb.dao.Daolmpl;class Delete extends JFrame implements ActionListenerprivate JButton yes;private JButton cancle;private JTextField text1;private String STNO;public Delete()Container c3 = this.getContentPane();c3.setBackground(Color.pink);c3.setLayout(new GridLayout(3, 1);c3.setFont(new Font("true",Font.TRUETYPE_FONT,13);JPanel p1 = new JPanel();p1.setBackground(Color.pink);JPanel p2 = new JPanel();p2.setBackground(Color.pink);JLabe11abel1 = new JLabel(" 刪除學生信息”,SwingConstants.CENTER);label1.setFont(new Font("true",Font.TRUETYPE_FONT,13);label1.setForeground(Color.blue);c3.add(label1);JLabel label2 = new JLabel(" 請輸入學號");text1 = new JTextField(10);p1.add(label2);p1.add(text1);c3.add(p1);yes = new JButton(" 確定");cancle = new JButton(" 退出");p2.add(yes);p2.add(cancle);c3.add(p2);yes.addActionListener(this);cancle.addActionListener(this);this.setTitle("刪除學生信息)this.setBounds(200,200,400,300);this.setVisible(true);public void actionPerformed(ActionEvent e)if(e.getSource(尸yes)DaoImpl di =new DaoImpl();STNO = text1.getText();di.delete(STNO);if(e.getSource(尸cancle)this.dispose();JOptionPane.showMessageDialog(this,”刪除成功! !");修改源碼:package com.lb.view;import java.awt.Color;import java.awt.Container;import java.awt.Font;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.SwingConstants;import com.lb.bean.Student;import com.lb.dao.DaoImpl;class Update extends JFrame implements ActionListenerprivate JTextField STNOText, SNAMEText, MAText, CHIText, JAVAText;private JButton b1,b2,b3;public Update()Container c4 = this.getContentPane();c4.setLayout(new GridLayout(5, 1);c4.setFont(new Font("true",Font.TRUETYPE_FONT,13);JPanel up1 = new JPanel();up1.setBackground(Color.pink);JPanel up2 = new JPanel();up2.setBackground(Color.pink);JPanel center = new JPanel(new GridLayout(4,4);center.setBackground(Color.pink);JPanel low = new JPanel();low.setBackground(Color.pink);JPanel low1 = new JPanel();low1.setBackground(Color.pink);JLabe11abel11 = new JLabel("需要修改的學號:");STNOText=new JTextField(15);up2.add(label11);up2.add(STNOText);b1=new JButton(" 查找");up2.add(b1);c4.add(up1);c4.add(up2);c4.add(center);SNAMEText=new JTextField(22);MAText=new JTextField(22);CHIText=new JTextField(22);JAVAText=new JTextField(22);center.add(new JLabel(" ");center.add(new JLabel(" 姓名:",SwingConstants.CENTER);center.add(SNAMEText);center.add(new JLabel(" ");center.add(new JLabel(" ");center.add( new JLabel(" 數(shù)學:",SwingConstants.CENTER);center.add(MAText);center.add(new JLabel(" ");center.add(new JLabel(" ");center.add(new JLabel(" 語文:",SwingConstants.CENTER);center.add(CHIText);center.add(new JLabel(" ");center.add(new JLabel(" ");center.add(new JLabel("java:", SwingConstants.CENTER);center.add(JAVAText);center.add(new JLabel(" ");c4.add(center);b2=new JButton("修改");b3=new JButton(" 退出");low1.add(b2);low1.add(b3);c4.add(low);c4.add(low1);bl.addActionListener(this);b2.addActionListener(this);b3.addActionListener(this);this.setTitle("修改信息)this.setBounds(200, 200, 400, 400); this.setVisible(true);public void actionPerformed(ActionEvent e) if (e.getSource() = b1) DaoImpl di = new DaoImpl();String num = STNOText.getText();Student stu = di.findStudentByNum(num);if(num.equals(stu.getNum()SNAMEText.setText(stu.getName();MAText.setText(String.valueOf(stu.getShuxue();CHIText.setText(String.valueOf(stu.getYuwen();JAVAText.setText(String.valueOf(stu.getJava();if (e.getSource() = b2) if (SNAMEText.getColumns() = 0 | MAText.getColumns() = 0| JAVAText.getColumns() = 0 | CHIText.getColumns() = 0)else Student a=new Student(SNAMEText.getText(),STNOText.getText(),Integer.parseInt(CHIText.getText(),Integer.parseInt(MAText.getText(), Integer.parseInt(JAVAText.getText();DaoImpl dl = new DaoImpl();dl.update(a);JOptionPane.showMessageDialog(this,”修改成功! !");if (e.getSource() = b3) this.dispose();查詢源碼:package com.lb.view; import java.awt.Color;import java.awt.Container;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.SwingConstants;import com.lb.bean.Student;import com.lb.dao.Daolmpl;class Query extends JFrame implements ActionListener private JTextField STNOText, SNAMEText, MAText, CHIText, JAVAText;private String STNO;private JButton b1, b2;public Query() Container c1 = this.getContentPane();c1.setLayout(new GridLayout(4, 1);JLabe11abel1 = new JLabel(" 查詢學生信息",SwingConstants.CENTER);JLabe11abel0 = new JLabel(" 請輸入你的學號",SwingConstants.CENTER);JPanel pp = new JPanel(new GridLayout(2, 1);pp.setBackground(Color.pink);pp.add(label1);pp.add(label0);c1.add(pp);JPanel p1 = new JPanel();p1.setBackground(Color.pink);STNOText = new JTextField(10);p1.add(STNOText);c1.add(p1);JPanel p2 = new JPanel();p2.setBackground(Color.pink);b1 = new JButton("查詢");b2 = new JButton("退出");b1.addActionListener(this);b2.addActionListener(this);p2.add(b1);p2.add(b2);c1.add(p2);JPanel center = new JPanel(new GridLayout(4, 4);center.setBackground(Color.pink);SNAMEText = new JTextField(30);CHIText = new JTextField(30);MAText = new JTextField(30);JAVAText = new JTextField(30);center.add(new JLabel(" ");center.add(new JLabel(" 姓名", SwingConstants.CENTER);center.add(SNAMEText);center.add(new JLabel(" ");center.add(new JLabel(" ");center.add(new JLabel(" 語文", SwingConstants.CENTER);center.add(CHIText);center.add(new JLabel(" ");center.add(new JLabel(" ");center.add(new JLabel(" 數(shù)學", SwingConstants.CENTER);center.add(MAText);center.add(new JLabel(" ");center.add(new JLabel(" ");center.add(new JLabel("java", SwingConstants.CENTER);center.add(JAVAText);center.add(new JLabel(" ");c1.add(center);this.setVisible(true);this.setBounds(200, 200, 400, 300);public void actionPerformed(ActionEvent e)if (e.getSource() = b1) STNO = STNOText.getText();DaoImpl dl = new DaoImpl();Student stu = dl.findStudentByNum(STNO);if(STNO).equals(stu.getNum() SNAMEText.setText(stu.getName();MAText.setText(String.valueOf(stu.getShuxue();CHIText.setText(String.valueOf(stu.getYuwen();JAVAText.setText(String.valueOf(stu.getJava();if (e.getSource() = b2) this.dispose();連庫源碼:package com.lb.dao;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.util.ArrayList;import java.util.List;import com.lb.bean.Student;public class Daolmpl public Student login(String num,String pass)Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;Student stu = new Student。;int sid = 0;try Class.forName("com.mysql.jdbc.Driver");connDriverManager.getConnection("jdbc:mysql:/localhost:3306/java","root","root"); String sql = "select * from user where num = ? and pass = ?" ps = conn.prepareStatement(sql);ps.setString(1, num);ps.setString(2, pass);rs = ps.executeQuery();while(rs.next()sid = rs.getInt("sid");String sql2 = "select * from student where id = "+sid;ps = conn.prepareStatement(sql);rs = ps.executeQuery();while(rs.next()stu.setId(rs.getInt("id");stu.setJava(rs.getInt("java"); stu.setName(rs.getString("name"); stu.setNum(rs.getString("num"); stu.setShuxue(rs.getInt("shuxue"); stu.setYuwen(rs.getInt("yuwen"); catch (ClassNotFoundException e) / TODO Auto-generated catch block e.printStackTrace(); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace();finallytry if(ps != null) ps.close();if(conn != null) conn.close(); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace();return stu;public void inseter(Student stu)Connection conn = null;PreparedStatement ps = null;try Class.forName("com.mysql.jdbc.Driver");connDriverManager.getConnection("jdbc:mysql:/localhost:3306/java","root","root"); String sql ="insert into student values(null,?,?,?,?,?)"ps = conn.prepareStatement(sql);ps.setString(1, stu.getName();ps.setString(2,stu.getNum();ps.setInt(3, stu.getYuwen();ps.setInt(4, stu.getShuxue();ps.setInt(5, stu.getJava();ps.executeUpdate(); catch (ClassNotFoundException e) / TODO Auto-generated catch block e.printStackTrace(); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace();finallytry if(ps != null)ps.close();if(conn != null) conn.close(); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace();public void delete(String num)Connection conn = null;PreparedStatement ps = null;try Class.forName("com.mysql.jdbc.Driver");connDriverManager.getConnection("jdbc:mysql:/localhost:3306/java","root","root"); String sql = "delete from student where num = ?"ps = conn.prepareStatement(sql);ps.setString(1, num);ps.executeUpdate(); catch (ClassNotFoundException e) / TODO Auto-generated catch block e.printStackTrace(); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace();finallytry if(ps != null) ps.close();if(conn != null) conn.close(); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace();public void update(Student stu)Connection conn = null;PreparedStatement ps = null;try Class.forName("com.mysql.jdbc.Driver"); connDriverManager.getConnection("jdbc:mysql:/localhost:3306/java","root","root");String sql = "update student set name = ?,yuwen = ?,shuxue = ?,java = ? where num = ?" ps = conn.prepareStatement(sql);ps.setString(1, stu.getName();ps.setInt(2, stu.getYuwen();ps.setInt(3, stu.getShuxue();ps.setInt(4, stu.getJava();ps.setString(5, stu.getNum();ps.executeUpdate(); catch (ClassNotFoundException e) / TODO Auto-generated catch block e.printStackTrace(); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace();finally try if(ps != null) ps.close();if(conn != null) conn.close(); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace();public List<Student> query()List<Student> li = new ArrayList<Student>();Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;try Class.forName("com.mysql.jdbc.Driver"); connDriverManager.getConnection("jdbc:mysql:/localhost:3306/java","root","root");String sql = "select * from student"ps = conn.prepareStatement(sql);rs = ps.executeQuery();while(rs.next()Student stu = new Student。; stu.setId(rs.getInt("id");stu.setName(rs.getString("name"); stu.setNum(rs.getString("num"); stu.setYuwen(rs.getInt("yuwen"); stu.setShuxue(rs.getInt("shuxue"); stu.setJava(rs.getInt("java");li.add(stu); catch (ClassNotFoundException e) / TODO Auto-generated catch block e.printStackTrace(); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace();finallytry if(rs != null) rs.close();if(ps != null) ps.close();if(conn != null) conn.close(); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace();return li;

注意事項

本文(Java學生課程設計源碼要點)為本站會員(簡****9)主動上傳,裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對上載內(nèi)容本身不做任何修改或編輯。 若此文所含內(nèi)容侵犯了您的版權或隱私,請立即通知裝配圖網(wǎng)(點擊聯(lián)系客服),我們立即給予刪除!

溫馨提示:如果因為網(wǎng)速或其他原因下載失敗請重新下載,重復下載不扣分。




關于我們 - 網(wǎng)站聲明 - 網(wǎng)站地圖 - 資源地圖 - 友情鏈接 - 網(wǎng)站客服 - 聯(lián)系我們

copyright@ 2023-2025  zhuangpeitu.com 裝配圖網(wǎng)版權所有   聯(lián)系電話:18123376007

備案號:ICP2024067431-1 川公網(wǎng)安備51140202000466號


本站為文檔C2C交易模式,即用戶上傳的文檔直接被用戶下載,本站只是中間服務平臺,本站所有文檔下載所得的收益歸上傳人(含作者)所有。裝配圖網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對上載內(nèi)容本身不做任何修改或編輯。若文檔所含內(nèi)容侵犯了您的版權或隱私,請立即通知裝配圖網(wǎng),我們立即給予刪除!