⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 editstuinformation.java

📁 java编写的与SQL数据连接的好例子~~功能很完善,可以做实训直接交
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package stuMS;import java.awt.event.*;import java.awt.*;import javax.swing.*;/** * * @author Administrator */public class EditStuInformation extends stuInformationJFrame implements ActionListener {        String SnoStr = null;    int intX = 90,intY = 4;    public EditStuInformation() {        this.setTitle("修改学生信息");        this.setResizable(false);        Sno.setEditable(false);        Sno.setText("请查询学号");        Sname.setEditable(false);        Ssex.setEditable(false);        Sethnic.setEditable(false);        Sbirth.setEditable(false);        Sdate.setEditable(false);        Smajor.setEditable(false);        Scollege.setEditable(false);        Shometown.setEditable(false);        this.setLocationRelativeTo(rootPane);    }    public void downInit(){        searchStuInformationButton.setText("查询");        searchStuInformationButton.setFont(new Font("Dialog",0,12));        controlPanel.add(searchStuInformationButton);        searchStuInformationButton.setBounds(intX, intY, 62, 30);        intX += 52;        alterStuInformationButton.setText("修改");        alterStuInformationButton.setFont(new Font("Dialog",0,12));        controlPanel.add(alterStuInformationButton);        alterStuInformationButton.setBounds(intX, intY, 62, 30);        intX += 52;        clearStuInformationButton.setText("清 空");        clearStuInformationButton.setFont(new Font("Dialog",0,12));        controlPanel.add(clearStuInformationButton);        clearStuInformationButton.setBounds(intX, intY, 62, 30);        intX += 52;        exitButton.setText("退 出");        exitButton.setFont(new Font("Dialog",0,12));        controlPanel.add(exitButton);        exitButton.setBounds(intX, intY, 62, 30);                searchStuInformationButton.setEnabled(true);        alterStuInformationButton.setEnabled(false);        clearStuInformationButton.setEnabled(true);        exitButton.setEnabled(true);        searchStuInformationButton.removeActionListener(this);        alterStuInformationButton.removeActionListener(this);        clearStuInformationButton.removeActionListener(this);        exitButton.removeActionListener( this);                searchStuInformationButton.addActionListener(this);        alterStuInformationButton.addActionListener(this);        clearStuInformationButton.addActionListener(this);        exitButton.addActionListener(this);    }    public void actionPerformed(ActionEvent e) {        Object obj = e.getSource();        String s[] = new String[9];        if (obj == exitButton) { //            this.dispose();        } else if (obj == searchStuInformationButton) {            StuInfoSearchSnum searchSno = new StuInfoSearchSnum(this,true);            //searchSno.pack();            searchSno.setVisible(true);            try{                SnoStr = searchSno.getSnum();            }catch(Exception ex){                JOptionPane.showMessageDialog(null, "没用查找到该学号");                                     }            StuBean searchStu = new StuBean();            s = searchStu.stuSearch(SnoStr);            if(s == null){                JOptionPane.showMessageDialog(null, "记录不存在");                setNull();                Sno.setText("请查询学号");                                Sname.setEditable(false);                Ssex.setEditable(false);                Sethnic.setEditable(false);                Sbirth.setEditable(false);                Sdate.setEditable(false);                Smajor.setEditable(false);                Scollege.setEditable(false);                Shometown.setEditable(false);                return;            }            else{                Sno.setText(s[0]);                                Sname.setText(s[1]);                Ssex.setText(s[2]);                                Sbirth.setText(s[3]);                Sethnic.setText(s[4]);                Shometown.setText(s[5]);                Sdate.setText(s[6]);                Smajor.setText(s[7]);                Scollege.setText(s[8]);                                Sname.setEditable(true);                Ssex.setEditable(true);                                Sbirth.setEditable(true);                Sethnic.setEditable(true);                Shometown.setEditable(true);                Sdate.setEditable(true);                Smajor.setEditable(true);                Scollege.setEditable(true);                                alterStuInformationButton.setEnabled(true);                            }                    } else if (obj == alterStuInformationButton) { //            StuBean addStu = new StuBean();            addStu.stuModify(Sno.getText(), Sname.getText(), Ssex.getText(), Sbirth.getText(), Sethnic.getText(),                    Shometown.getText(), Sdate.getText(), Smajor.getText(), Scollege.getText());            //this.setNull();        } else if (obj == clearStuInformationButton) { //            setNull();            JOptionPane.showMessageDialog(null, "已清空!");        }    }      public static void main(String args[]) {        java.awt.EventQueue.invokeLater(new Runnable() {            public void run() {                new EditStuInformation().setVisible(true);            }        });    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -