📄 squeaward.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.*;class SqueAward extends JDialog{ Statement ps; ResultSet rs; Connection con; String url; String strType; String strEvent; String strPTime; String strPResult; //Object[][] rowData = new Object[10][6]; //String[] columnNames = {"姓名","班级","类别","事件","处理时间","处理结果"}; //JTable jTable = new JTable(rowData, columnNames); JPanel panel = new JPanel(); JPanel panelb = new JPanel(); JPanel panelt = new JPanel(); JLabel labType = new JLabel(); JTextField txtType = new JTextField(); JLabel labEvent = new JLabel(); JTextField txtEvent = new JTextField(); JLabel labPTime = new JLabel(); JTextField txtPTime = new JTextField(); JLabel labPResult = new JLabel(); JTextField txtPResult = new JTextField(); JButton sure = new JButton(); JButton cancel = new JButton(); public SqueAward(Frame frame, String title, boolean modal) { super(frame, title, modal); try { jbInit(); pack(); } catch (Exception ex) { ex.printStackTrace(); } } public SqueAward() { 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()){ strType = rs.getString(3); strEvent = rs.getString(4); strPTime = rs.getString(5); strPResult = 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(); } labType.setText("类 别"); txtType.setEditable(false); txtType.setText(strType); labEvent.setText("事 件"); txtEvent.setEditable(false); txtEvent.setText(strEvent); labPTime.setText("处理时间"); txtPTime.setEditable(false); txtPTime.setText(strPTime); labPResult.setText("处理结果"); txtPResult.setEditable(false); txtPResult.setText(strPResult); sure.setText("确定"); sure.setText("确定"); sure.addActionListener(new sque_Award_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,labType); LayoutUtil.add(panel,GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER,1,0,1,0,1,1,txtType); LayoutUtil.add(panel,GridBagConstraints.NONE,GridBagConstraints.CENTER,0,0,2,0,1,1,labEvent); LayoutUtil.add(panel,GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER,1,0,3,0,1,1,txtEvent); LayoutUtil.add(panel,GridBagConstraints.NONE,GridBagConstraints.CENTER,0,0,0,1,1,1,labPTime); LayoutUtil.add(panel,GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER,1,0,1,1,1,1,txtPTime); LayoutUtil.add(panel,GridBagConstraints.NONE,GridBagConstraints.CENTER,0,0,2,1,1,1,labPResult); LayoutUtil.add(panel,GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER,1,0,3,1,1,1,txtPResult); panelb.setLayout(new GridBagLayout()); LayoutUtil.add(panelb,GridBagConstraints.NONE,GridBagConstraints.CENTER,0,0,0,0,1,1,sure); //panelt.setLayout(new GridBagLayout()); //LayoutUtil.add(panelt,GridBagConstraints.NONE,GridBagConstraints.CENTER,0,0,0,0,1,1,jTable); //LayoutUtil.add(panelb,GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER,0,0,1,0,1,1,cancel); //this.getContentPane().add(panelt,BorderLayout.NORTH); this.getContentPane().add(panel,BorderLayout.CENTER); this.getContentPane().add(panelb,BorderLayout.SOUTH); this.setBounds(100, 100, 400, 400); this.setVisible(true); } void sure_actionPerformed(ActionEvent e) { this.dispose(); } }class sque_Award_sure_actionAdapter implements java.awt.event.ActionListener { SqueAward adaptee; sque_Award_sure_actionAdapter(SqueAward adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.sure_actionPerformed(e); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -