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

📄 lookclass.java

📁 java netbeans 学习程序合集
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * LookClass.java
 *
 * Created on 2007年8月28日, 下午8:23
 */

package org.Adam;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import javax.swing.JFrame;
import javax.swing.table.DefaultTableModel;
import javax.swing.JTextField;

/**
 *
 * @author  Administrator
 */
public class LookClass extends javax.swing.JFrame {
    Update updateclass=new Update();
    public  String ID=new String();
     ResultSet rs=null;
    /** Creates new form LookClass */
    public LookClass() {
        initComponents();
        this.setLocationRelativeTo(this);
        this.setResizable(false);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" 生成的代码 ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("\u6d4f\u89c8\u6240\u6709\u73ed\u7ea7");
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("\u6d4f\u89c8\u6240\u6709\u73ed\u7ea7"));
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jScrollPane1.setViewportView(jTable1);

        jButton1.setText("\u6d4f\u89c8\u6240\u6709\u73ed\u7ea7");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("\u4fee\u6539\u73ed\u7ea7\u4fe1\u606f");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(58, 58, 58)
                .add(jButton1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 166, Short.MAX_VALUE)
                .add(jButton2)
                .add(58, 58, 58))
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 472, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jButton1)
                    .add(jButton2))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 14, Short.MAX_VALUE)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 394, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO 将在此处添加您的处理代码:
        updateclass.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
        ((JTextField)(((java.awt.Container)(updateclass.getContentPane().getComponent(1))).getComponent(3))).setText(jTable1.getValueAt(jTable1.getSelectedRow(),0).toString());
        ((JTextField)(((java.awt.Container)(updateclass.getContentPane().getComponent(1))).getComponent(5))).setText(jTable1.getValueAt(jTable1.getSelectedRow(),1).toString());
        ((JTextField)(((java.awt.Container)(updateclass.getContentPane().getComponent(1))).getComponent(7))).setText(jTable1.getValueAt(jTable1.getSelectedRow(),2).toString());
        ((JTextField)(((java.awt.Container)(updateclass.getContentPane().getComponent(1))).getComponent(6))).setText(jTable1.getValueAt(jTable1.getSelectedRow(),3).toString());
       // ((JTextField)(((java.awt.Container)(updateclass.getContentPane().getComponent(1))).getComponent(2))).setText(jTable1.getValueAt(jTable1.getSelectedRow(),4).toString());
        updateclass.setVisible(true);
        updateclass.setResizable(false);
        updateclass.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
              initData();
              updateclass.dispose();
               
            }
        });
       
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO 将在此处添加您的处理代码:
        initData();
    }//GEN-LAST:event_jButton1ActionPerformed
    
    public void initData(){
        Vector<Vector> data=new Vector();
        Vector<String> head=new Vector();
        String sql="select 年级,班级,专业,辅导员,其他  from 班级信息 order by 年级 ";
        DefaultTableModel tableModel=(DefaultTableModel)this.jTable1.getModel();
        DB dB=new DB();
      /*  headGrade=dB.doClassQuery(sql1);
        this.jComboBoxGrade.addItem(headGrade);*/
       // String Grade=this.jComboBoxGrade.getSelectedItem().toString();
        head=dB.doClassTableHead(sql);
        data=dB.doClassQuery(sql);
        tableModel.setDataVector(data,head);
        this.jTable1.setModel(tableModel);
        ((DefaultTableModel)jTable1.getModel()).fireTableStructureChanged();
        dB.closeAccessConnection();
       /* this.jScrollPane1.repaint();
        jTable1.repaint();*/
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new LookClass().setVisible(true);
            }
        });
    }
    
    // 变量声明 - 不进行修改//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    // 变量声明结束//GEN-END:variables
    
    
    
    public class Update extends javax.swing.JFrame {
    public String ID=new String();

    private ResultSet rs;
    /** Creates new form UpdateClass */
    public Update() {
        initComponents();
        this.setLocationRelativeTo(this);
        this.setResizable(false);
      this.jTextFieldUpdateGrade.setEnabled(false);
        this.jTextFieldUpdateClass.setEnabled(false);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */

⌨️ 快捷键说明

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