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

📄 squefamily.java

📁 学生档案管理系统
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package 学生档案管理系统;/** * * @author Administrator */import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;public class SqueFamily extends JDialog{    Statement ps;    ResultSet rs;    Connection con;    String url;        String strName;    String strRelation;    String strPhoneNum;    String strJobAddress;        JPanel panel = new JPanel();         JPanel panelb = new JPanel();    JLabel labName = new JLabel();    JTextField txtName = new JTextField();    JLabel labRelation = new JLabel();    JTextField txtRelation = new JTextField();    JLabel labPhoneNum = new JLabel();    JTextField txtPhoneNum = new JTextField();    JLabel labJobAddress = new JLabel();    JTextField txtJobAddress = new JTextField();        JButton sure = new JButton();    JButton cancel = new JButton();            public SqueFamily(Frame frame, String title, boolean modal) {        super(frame, title, modal);        try {            jbInit();            pack();        }        catch (Exception ex) {            ex.printStackTrace();        }    }        public SqueFamily() {        this(null, "", true);    }    private void jbInit() throws Exception{        try {                try {                    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");                    Connection con = DriverManager.getConnection("jdbc:odbc:学生档案","", "");                    ps = con.createStatement();                }                catch (Exception err) {                    String error = err.getMessage();                    JOptionPane.showMessageDialog(null, "连接数据库错误!");                }                try {                    String strSNum = "'"+MainFrame.strSNum+"'";                    String sqlStr = "Select * from 家庭成员表 where 学号 ="+ strSNum;                    rs = ps.executeQuery(sqlStr);                      while(rs.next()){                        strName = rs.getString(3);                                                strRelation = rs.getString(4);                        strPhoneNum = rs.getString(5);                        strJobAddress = rs.getString(6);                    }                    ps.close();                }                catch (SQLException sqle) {                    String error = sqle.getMessage();                    JOptionPane.showMessageDialog(null, error);                    sqle.printStackTrace();                }            }            catch (Exception ex) {                ex.getMessage();                String error = ex.getMessage();                JOptionPane.showMessageDialog(null, error);                ex.printStackTrace();            }                labName.setText("姓      名 ");        txtName.setEditable(false);        txtName.setText(strName);        labRelation.setText("与本人关系");        txtRelation.setEditable(false);        txtRelation.setText(strRelation);        labPhoneNum.setText("联系电话");        txtPhoneNum.setEditable(false);        txtPhoneNum.setText(strPhoneNum);        labJobAddress.setText("所在单位");        txtJobAddress.setEditable(false);        txtJobAddress.setText(strJobAddress);                sure.setText("确定");        sure.addActionListener(new sque_Family_sure_actionAdapter(this));        //cancel.setText("取消");                panel.setBorder(BorderFactory.createLoweredBevelBorder());        panel.setLayout(new GridBagLayout());                LayoutUtil.add(panel,GridBagConstraints.NONE,GridBagConstraints.CENTER,0,0,0,0,1,1,labName);        LayoutUtil.add(panel,GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER,1,0,1,0,1,1,txtName);        LayoutUtil.add(panel,GridBagConstraints.NONE,GridBagConstraints.CENTER,0,0,2,0,1,1,labRelation);        LayoutUtil.add(panel,GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER,1,0,3,0,1,1,txtRelation);                LayoutUtil.add(panel,GridBagConstraints.NONE,GridBagConstraints.CENTER,0,0,0,1,1,1,labPhoneNum);        LayoutUtil.add(panel,GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER,1,0,1,1,1,1,txtPhoneNum);        LayoutUtil.add(panel,GridBagConstraints.NONE,GridBagConstraints.CENTER,0,0,2,1,1,1,labJobAddress);        LayoutUtil.add(panel,GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER,1,0,3,1,1,1,txtJobAddress);                panelb.setLayout(new GridBagLayout());        LayoutUtil.add(panelb,GridBagConstraints.NONE,GridBagConstraints.CENTER,0,0,0,0,1,1,sure);        //LayoutUtil.add(panelb,GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER,0,0,1,0,1,1,cancel);                this.getContentPane().add(panel,BorderLayout.CENTER);        this.getContentPane().add(panelb,BorderLayout.SOUTH);        this.setBounds(100, 100, 400, 300);        this.setVisible(true);    } void sure_actionPerformed(ActionEvent e) {        this.dispose();    }    }class sque_Family_sure_actionAdapter    implements java.awt.event.ActionListener {    SqueFamily adaptee;    sque_Family_sure_actionAdapter(SqueFamily adaptee) {        this.adaptee = adaptee;    }    public void actionPerformed(ActionEvent e) {        adaptee.sure_actionPerformed(e);    }}

⌨️ 快捷键说明

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