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

📄 sort.java

📁 用java实现了一个学籍管理系统
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. *//* * sort.java * * Created on 2009-4-1, 21:24:42 */package stuinfomanage;import java.sql.ResultSet;import java.sql.SQLException;import java.util.logging.Level;import java.util.logging.Logger;/** * * @author Administrator */public class sort extends javax.swing.JFrame {    /** Creates new form sort */    public sort() {        initComponents();    }    /** 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.     */    @SuppressWarnings("unchecked")    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents    private void initComponents() {        jButton1 = new javax.swing.JButton();        jLabel1 = new javax.swing.JLabel();        jScrollPane1 = new javax.swing.JScrollPane();        TA_sort = new javax.swing.JTextArea();        jLabel2 = new javax.swing.JLabel();        CB_sort = new javax.swing.JComboBox();        jButton2 = new javax.swing.JButton();        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);        jButton1.setText("排序");        jButton1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                sort(evt);            }        });        jLabel1.setText("成绩排序");        TA_sort.setColumns(20);        TA_sort.setEditable(false);        TA_sort.setRows(5);        jScrollPane1.setViewportView(TA_sort);        jLabel2.setText("选择排序标准:");        CB_sort.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Compiler", "Soft Engineering", " " }));        jButton2.setText("退出");        jButton2.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                end(evt);            }        });        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(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)                    .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 69, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 310, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)                        .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()                            .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)                            .add(CB_sort, 0, 0, Short.MAX_VALUE))                        .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()                            .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 91, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                            .add(18, 18, 18)                            .add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 91, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))                .addContainerGap(22, Short.MAX_VALUE))        );        layout.setVerticalGroup(            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)            .add(layout.createSequentialGroup()                .addContainerGap()                .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 116, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                .add(6, 6, 6)                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)                    .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 23, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                    .add(CB_sort, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))                .add(18, 18, 18)                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)                    .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 34, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                    .add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 34, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))                .addContainerGap(19, Short.MAX_VALUE))        );        pack();    }// </editor-fold>//GEN-END:initComponents    private void end(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_end        // TODO add your handling code here:        this.setVisible(false);    }//GEN-LAST:event_end    private void sort(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sort        try {            // TODO add your handling code here:            int item = 0;            String n = "";            item = CB_sort.getSelectedIndex();            if (item == 0) {                n = "Compiler";            } else if (item == 1) {                n = "SoftEngineering";            }            TA_sort.setText("");            ResultSet rs=null;            DataOpera Data = new DataOpera();            rs=Data.SortOp(n);            while(rs.next())            {                String sort=rs.getString(1)+"\t"+rs.getString(2)+"\t"+rs.getString(3)+"\n";                TA_sort.append(sort);            }        } catch (SQLException ex) {            Logger.getLogger(sort.class.getName()).log(Level.SEVERE, null, ex);        } catch (ClassNotFoundException ex) {            Logger.getLogger(sort.class.getName()).log(Level.SEVERE, null, ex);        }    }//GEN-LAST:event_sort    /**    * @param args the command line arguments    */  /*  public static void main(String args[]) {        java.awt.EventQueue.invokeLater(new Runnable() {            public void run() {                new sort().setVisible(true);            }        });    }*/    // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JComboBox CB_sort;    private javax.swing.JTextArea TA_sort;    private javax.swing.JButton jButton1;    private javax.swing.JButton jButton2;    private javax.swing.JLabel jLabel1;    private javax.swing.JLabel jLabel2;    private javax.swing.JScrollPane jScrollPane1;    // End of variables declaration//GEN-END:variables}

⌨️ 快捷键说明

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