首页 > 代码库 > Java综合性实验

Java综合性实验

 

NewJFrame

技术分享
package scoreaynalysissystem;/** * * @hl_mark *  */import java.awt.Graphics;import java.io.*;import java.util.*;import java.util.logging.Level;import java.util.logging.Logger;import javax.swing.JFileChooser;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.RowFilter;import javax.swing.table.DefaultTableModel;import javax.swing.table.TableModel;import javax.swing.table.TableRowSorter;public class NewJFrame extends javax.swing.JFrame {    int maxScore , minScore , tot ; double averageScore;    int cnt[] = new int[5] ;  double percent[] = new double[5] ;     ArrayList studentList = new ArrayList();    private Object output;        void updateDate(){        maxScore = 0 ; minScore = 100; averageScore = 0 ;        for( int i = 0 ; i < 5 ; ++i ) {             cnt[i] = 0 ;            percent[i] = 0;        }        tot = studentList.size();        for( int i = 0 ; i < tot ;  ++i ){            Student tmp = (Student)studentList.get(i);            int score = tmp.get_score();            averageScore += (double)score ;            if( score > maxScore ) maxScore = score ;            if( score < minScore ) minScore = score ;            if( score >= 0 && score < 60 ) cnt[4]++;            else if( score >=60 && score < 70 ) cnt[3]++;            else if( score >=70 && score < 80 ) cnt[2]++;            else if( score >=80 && score < 90 ) cnt[1]++;            else cnt[0]++;        }        averageScore /= tot;        for( int i = 0 ; i < 5 ; ++i ) percent[i] = (double)cnt[i]/tot*100.0;    }        public NewJFrame() {        initComponents();    }    @SuppressWarnings("unchecked")    // <editor-fold defaultstate="collapsed" desc="Generated Code">                              private void initComponents() {        jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();        jCheckBoxMenuItem2 = new javax.swing.JCheckBoxMenuItem();        jPanel2 = new javax.swing.JPanel();        jPanel3 = new javax.swing.JPanel();        jMenuBar2 = new javax.swing.JMenuBar();        jMenu2 = new javax.swing.JMenu();        jMenu3 = new javax.swing.JMenu();        jMenu4 = new javax.swing.JMenu();        jMenuBar3 = new javax.swing.JMenuBar();        jMenu5 = new javax.swing.JMenu();        jMenu6 = new javax.swing.JMenu();        jMenuBar4 = new javax.swing.JMenuBar();        jMenu7 = new javax.swing.JMenu();        jMenu8 = new javax.swing.JMenu();        jMenuBar5 = new javax.swing.JMenuBar();        jMenu9 = new javax.swing.JMenu();        jMenu10 = new javax.swing.JMenu();        jMenuBar6 = new javax.swing.JMenuBar();        jMenu11 = new javax.swing.JMenu();        jMenu12 = new javax.swing.JMenu();        jMenuBar7 = new javax.swing.JMenuBar();        jMenu13 = new javax.swing.JMenu();        jMenu14 = new javax.swing.JMenu();        jSeparator3 = new javax.swing.JSeparator();        jLayeredPane1 = new javax.swing.JLayeredPane();        jtfSearch = new javax.swing.JTextField();        jlbSearch = new javax.swing.JLabel();        jPanel1 = new javax.swing.JPanel();        jPanel5 = new javax.swing.JPanel();        jlbMaxS = new javax.swing.JLabel();        jlbMinS = new javax.swing.JLabel();        jlbAvgS = new javax.swing.JLabel();        jlbWell = new javax.swing.JLabel();        jlbGood = new javax.swing.JLabel();        jlbMiddle = new javax.swing.JLabel();        jlbPass = new javax.swing.JLabel();        jlbFail = new javax.swing.JLabel();        jButton1 = new javax.swing.JButton();        jButton2 = new javax.swing.JButton();        jLabel11 = new javax.swing.JLabel();        jLabel12 = new javax.swing.JLabel();        jLabel13 = new javax.swing.JLabel();        jLabel14 = new javax.swing.JLabel();        jLabel15 = new javax.swing.JLabel();        jTextField7 = new javax.swing.JTextField();        jTextField8 = new javax.swing.JTextField();        jTextField9 = new javax.swing.JTextField();        jTextField10 = new javax.swing.JTextField();        jTextField11 = new javax.swing.JTextField();        jLabel16 = new javax.swing.JLabel();        jLabel17 = new javax.swing.JLabel();        jLabel18 = new javax.swing.JLabel();        jLabel19 = new javax.swing.JLabel();        jLabel20 = new javax.swing.JLabel();        jLabel21 = new javax.swing.JLabel();        jLabel22 = new javax.swing.JLabel();        jLabel23 = new javax.swing.JLabel();        jLabel25 = new javax.swing.JLabel();        jLabel26 = new javax.swing.JLabel();        jLabelM = new javax.swing.JLabel();        jLabelm = new javax.swing.JLabel();        jLabela = new javax.swing.JLabel();        jLabels0 = new javax.swing.JLabel();        jLabels1 = new javax.swing.JLabel();        jLabels3 = new javax.swing.JLabel();        jLabels2 = new javax.swing.JLabel();        jLabels4 = new javax.swing.JLabel();        jLabelp0 = new javax.swing.JLabel();        jLabelp1 = new javax.swing.JLabel();        jLabelp2 = new javax.swing.JLabel();        jLabelp3 = new javax.swing.JLabel();        jLabelp4 = new javax.swing.JLabel();        jSeparator4 = new javax.swing.JSeparator();        jScrollPane2 = new javax.swing.JScrollPane();        jTable1 = new javax.swing.JTable();        jLabelfile = new javax.swing.JLabel();        jlbScore = new javax.swing.JLabel();        jlbAnalysis = new javax.swing.JLabel();        jbSearch = new javax.swing.JButton();        jMenuBar1 = new javax.swing.JMenuBar();        jMenu1 = new javax.swing.JMenu();        jmOpean0 = new javax.swing.JMenuItem();        jmSave0 = new javax.swing.JMenuItem();        jSeparator1 = new javax.swing.JPopupMenu.Separator();        jmOpean1 = new javax.swing.JMenuItem();        jmSave1 = new javax.swing.JMenuItem();        jSeparator2 = new javax.swing.JPopupMenu.Separator();        jmClear = new javax.swing.JMenuItem();        jCheckBoxMenuItem1.setSelected(true);        jCheckBoxMenuItem1.setText("jCheckBoxMenuItem1");        jCheckBoxMenuItem2.setSelected(true);        jCheckBoxMenuItem2.setText("jCheckBoxMenuItem2");        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);        jPanel2.setLayout(jPanel2Layout);        jPanel2Layout.setHorizontalGroup(            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGap(0, 100, Short.MAX_VALUE)        );        jPanel2Layout.setVerticalGroup(            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGap(0, 22, Short.MAX_VALUE)        );        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);        jPanel3.setLayout(jPanel3Layout);        jPanel3Layout.setHorizontalGroup(            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGap(0, 100, Short.MAX_VALUE)        );        jPanel3Layout.setVerticalGroup(            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGap(0, 100, Short.MAX_VALUE)        );        jMenu2.setText("File");        jMenuBar2.add(jMenu2);        jMenu3.setText("Edit");        jMenuBar2.add(jMenu3);        jMenu4.setText("jMenu4");        jMenu5.setText("File");        jMenuBar3.add(jMenu5);        jMenu6.setText("Edit");        jMenuBar3.add(jMenu6);        jMenu7.setText("File");        jMenuBar4.add(jMenu7);        jMenu8.setText("Edit");        jMenuBar4.add(jMenu8);        jMenu9.setText("File");        jMenuBar5.add(jMenu9);        jMenu10.setText("Edit");        jMenuBar5.add(jMenu10);        jMenu11.setText("File");        jMenuBar6.add(jMenu11);        jMenu12.setText("Edit");        jMenuBar6.add(jMenu12);        jMenu13.setText("File");        jMenuBar7.add(jMenu13);        jMenu14.setText("Edit");        jMenuBar7.add(jMenu14);        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);        setTitle("ScoreAnalysisSystem");        jLayeredPane1.setBackground(new java.awt.Color(204, 204, 255));        jLayeredPane1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));        jtfSearch.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jtfSearchActionPerformed(evt);            }        });        jlbSearch.setText("       输入学号或姓名或成绩可以自动查询,点击表头列头可以排序");        jlbSearch.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));        jPanel1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));        jPanel5.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));        jlbMaxS.setText("最高分");        jlbMinS.setText("最低分");        jlbAvgS.setText("平均分");        jlbWell.setText("优秀 ( 90 - 100 )");        jlbGood.setText("良好 ( 80 - 89 )");        jlbMiddle.setText("中等 ( 70 - 79 )");        jlbPass.setText("及格 ( 60 - 69 )");        jlbFail.setText("不及格( 0 - 59 )");        jButton1.setText("显示柱状分析图");        jButton1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton1ActionPerformed(evt);            }        });        jButton2.setText("显示饼状分析图");        jButton2.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton2ActionPerformed(evt);            }        });        jLabel11.setText("人,占");        jLabel12.setText("人,占");        jLabel13.setText("人,占");        jLabel14.setText("人,占");        jLabel15.setText("人,占");        jTextField7.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jTextField7ActionPerformed(evt);            }        });        jTextField8.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jTextField8ActionPerformed(evt);            }        });        jTextField9.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jTextField9ActionPerformed(evt);            }        });        jTextField10.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jTextField10ActionPerformed(evt);            }        });        jTextField11.setToolTipText("");        jTextField11.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jTextField11ActionPerformed(evt);            }        });        jLabel16.setText(" %");        jLabel17.setText(" %");        jLabel18.setText(" %");        jLabel19.setText(" %");        jLabel20.setText(" %");        jLabel21.setText(" %");        jLabel22.setText(" %");        jLabel23.setText(" %");        jLabel25.setText(" %");        jLabel26.setText(" %");        jLabelM.setBackground(new java.awt.Color(255, 255, 255));        jLabelM.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));        jLabelm.setBackground(new java.awt.Color(255, 255, 255));        jLabelm.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));        jLabela.setBackground(new java.awt.Color(255, 255, 255));        jLabela.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));        jLabels0.setBackground(new java.awt.Color(255, 255, 255));        jLabels0.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));        jLabels1.setBackground(new java.awt.Color(255, 255, 255));        jLabels1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));        jLabels3.setBackground(new java.awt.Color(255, 255, 255));        jLabels3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));        jLabels2.setBackground(new java.awt.Color(255, 255, 255));        jLabels2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));        jLabels4.setBackground(new java.awt.Color(255, 255, 255));        jLabels4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));        jLabelp0.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));        jLabelp1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));        jLabelp2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));        jLabelp3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));        jLabelp4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);        jPanel5.setLayout(jPanel5Layout);        jPanel5Layout.setHorizontalGroup(            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel5Layout.createSequentialGroup()                .addContainerGap()                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addGroup(jPanel5Layout.createSequentialGroup()                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)                            .addComponent(jlbMinS, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                            .addComponent(jlbMaxS, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                            .addComponent(jlbGood, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                            .addComponent(jlbPass, javax.swing.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE)                            .addComponent(jlbMiddle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                            .addComponent(jlbFail)                            .addComponent(jlbAvgS, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                            .addComponent(jLabelm, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)                            .addComponent(jLabelM, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)                            .addComponent(jLabela, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)))                    .addGroup(jPanel5Layout.createSequentialGroup()                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)                            .addGroup(jPanel5Layout.createSequentialGroup()                                .addComponent(jlbWell, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                                    .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)                                        .addComponent(jLabels0, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)                                        .addComponent(jLabels1, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)                                        .addComponent(jLabels3, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))                                    .addComponent(jLabels4, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)                                    .addComponent(jLabels2, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)                                    .addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                                    .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                                    .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                                    .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                                    .addComponent(jLabel11, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)                                    .addComponent(jLabelp1, javax.swing.GroupLayout.DEFAULT_SIZE, 37, Short.MAX_VALUE)                                    .addComponent(jLabelp3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                                    .addComponent(jLabelp4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                                    .addComponent(jLabelp2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                                    .addComponent(jLabelp0, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))                                .addGap(18, 18, 18)                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                                    .addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)                                    .addComponent(jLabel25, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)                                    .addComponent(jLabel26, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)                                    .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)                                    .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)))                            .addGroup(jPanel5Layout.createSequentialGroup()                                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)                                .addGap(18, 18, 18)                                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)                                .addGap(15, 15, 15)))                        .addGap(325, 325, 325)                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                            .addGroup(jPanel5Layout.createSequentialGroup()                                .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                                .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))                            .addGroup(jPanel5Layout.createSequentialGroup()                                .addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                                .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))                            .addGroup(jPanel5Layout.createSequentialGroup()                                .addComponent(jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                                .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))                            .addGroup(jPanel5Layout.createSequentialGroup()                                .addComponent(jTextField10, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                                .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))                            .addGroup(jPanel5Layout.createSequentialGroup()                                .addComponent(jTextField11, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                                .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)))))                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))        );        jPanel5Layout.setVerticalGroup(            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel5Layout.createSequentialGroup()                .addGap(32, 32, 32)                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)                    .addComponent(jlbMaxS, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(jLabelM, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))                .addGap(18, 18, 18)                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addComponent(jLabelm, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(jlbMinS, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))                .addGap(18, 18, 18)                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addComponent(jlbAvgS, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(jLabela, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))                .addGap(39, 39, 39)                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)                    .addGroup(jPanel5Layout.createSequentialGroup()                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                            .addGroup(jPanel5Layout.createSequentialGroup()                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)                                    .addComponent(jLabels0, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)                                    .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                                        .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)                                        .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                                        .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))                                    .addComponent(jlbWell, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                                    .addComponent(jLabelp0, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                                    .addComponent(jLabelp1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)                                    .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                                        .addComponent(jlbGood)                                        .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)                                        .addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                                        .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)                                        .addComponent(jLabels1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)                                        .addComponent(jLabel26, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))))                            .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)                                .addComponent(jLabels2, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                                    .addComponent(jLabel21, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)                                    .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)                                    .addComponent(jLabelp2, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))                            .addComponent(jlbMiddle, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))                        .addGap(11, 11, 11))                    .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                        .addComponent(jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                        .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)                    .addComponent(jlbPass, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                    .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                        .addComponent(jLabel25, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)                        .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)                        .addComponent(jLabelp3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))                    .addComponent(jLabels3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addGroup(jPanel5Layout.createSequentialGroup()                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                            .addComponent(jTextField10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                            .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)                            .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                            .addComponent(jTextField11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                            .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))                    .addGroup(jPanel5Layout.createSequentialGroup()                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)                            .addGroup(jPanel5Layout.createSequentialGroup()                                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                                    .addComponent(jlbFail, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)                                    .addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))                                .addGap(31, 31, 31))                            .addGroup(jPanel5Layout.createSequentialGroup()                                .addComponent(jLabels4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                                .addGap(32, 32, 32))                            .addGroup(jPanel5Layout.createSequentialGroup()                                .addComponent(jLabelp4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                                .addGap(32, 32, 32)))                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                            .addComponent(jButton1)                            .addComponent(jButton2))))                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))        );        jTable1.setModel(new javax.swing.table.DefaultTableModel(            new Object [][] {                {null, null, null},                {null, null, null},                {null, null, null},                {null, null, null}            },            new String [] {                "学号", "姓名", "成绩"            }        ) {            Class[] types = new Class [] {                java.lang.String.class, java.lang.String.class, java.lang.Integer.class            };            public Class getColumnClass(int columnIndex) {                return types [columnIndex];            }        });        jScrollPane2.setViewportView(jTable1);        if (jTable1.getColumnModel().getColumnCount() > 0) {            jTable1.getColumnModel().getColumn(0).setHeaderValue("学号");            jTable1.getColumnModel().getColumn(1).setHeaderValue("姓名");            jTable1.getColumnModel().getColumn(2).setHeaderValue("成绩");        }        jLabelfile.setText("  ");        jLabelfile.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);        jPanel1.setLayout(jPanel1Layout);        jPanel1Layout.setHorizontalGroup(            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel1Layout.createSequentialGroup()                .addGap(0, 0, 0)                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addComponent(jLabelfile, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                    .addGroup(jPanel1Layout.createSequentialGroup()                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 397, javax.swing.GroupLayout.PREFERRED_SIZE)                        .addGap(18, 18, 18)                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 397, Short.MAX_VALUE)))                .addContainerGap())            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                .addGroup(jPanel1Layout.createSequentialGroup()                    .addGap(0, 0, Short.MAX_VALUE)                    .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addGap(0, 0, Short.MAX_VALUE)))        );        jPanel1Layout.setVerticalGroup(            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel1Layout.createSequentialGroup()                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                    .addComponent(jScrollPane2))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addComponent(jLabelfile, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                .addGroup(jPanel1Layout.createSequentialGroup()                    .addGap(0, 235, Short.MAX_VALUE)                    .addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addGap(0, 236, Short.MAX_VALUE)))        );        jlbScore.setFont(new java.awt.Font("宋体", 1, 14)); // NOI18N        jlbScore.setText(" 成绩单");        jlbAnalysis.setFont(new java.awt.Font("宋体", 1, 14)); // NOI18N        jlbAnalysis.setText("  数据分析");        jbSearch.setText("查找");        jbSearch.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jbSearchActionPerformed(evt);            }        });        javax.swing.GroupLayout jLayeredPane1Layout = new javax.swing.GroupLayout(jLayeredPane1);        jLayeredPane1.setLayout(jLayeredPane1Layout);        jLayeredPane1Layout.setHorizontalGroup(            jLayeredPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)            .addGroup(jLayeredPane1Layout.createSequentialGroup()                .addComponent(jtfSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 270, javax.swing.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addComponent(jbSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addComponent(jlbSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 477, javax.swing.GroupLayout.PREFERRED_SIZE))            .addGroup(jLayeredPane1Layout.createSequentialGroup()                .addComponent(jlbScore, javax.swing.GroupLayout.PREFERRED_SIZE, 389, javax.swing.GroupLayout.PREFERRED_SIZE)                .addGap(155, 155, 155)                .addComponent(jlbAnalysis, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE))        );        jLayeredPane1Layout.setVerticalGroup(            jLayeredPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jLayeredPane1Layout.createSequentialGroup()                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)                .addGroup(jLayeredPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jtfSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(jbSearch)                    .addComponent(jlbSearch))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addGroup(jLayeredPane1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addComponent(jlbScore, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(jlbAnalysis, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))        );        jLayeredPane1.setLayer(jtfSearch, javax.swing.JLayeredPane.DEFAULT_LAYER);        jLayeredPane1.setLayer(jlbSearch, javax.swing.JLayeredPane.DEFAULT_LAYER);        jLayeredPane1.setLayer(jPanel1, javax.swing.JLayeredPane.DEFAULT_LAYER);        jLayeredPane1.setLayer(jlbScore, javax.swing.JLayeredPane.DEFAULT_LAYER);        jLayeredPane1.setLayer(jlbAnalysis, javax.swing.JLayeredPane.DEFAULT_LAYER);        jLayeredPane1.setLayer(jbSearch, javax.swing.JLayeredPane.DEFAULT_LAYER);        jMenu1.setText("文件");        jmOpean0.setText("打开文本文件成绩");        jmOpean0.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jmOpean0ActionPerformed(evt);            }        });        jMenu1.add(jmOpean0);        jmSave0.setText("另存为文本文件成绩");        jmSave0.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jmSave0ActionPerformed(evt);            }        });        jMenu1.add(jmSave0);        jMenu1.add(jSeparator1);        jmOpean1.setText("打开对象文件成绩");        jmOpean1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jmOpean1ActionPerformed(evt);            }        });        jMenu1.add(jmOpean1);        jmSave1.setText("另存为对象文件成绩");        jmSave1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jmSave1ActionPerformed(evt);            }        });        jMenu1.add(jmSave1);        jMenu1.add(jSeparator2);        jmClear.setText("清除数据");        jmClear.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jmClearActionPerformed(evt);            }        });        jMenu1.add(jmClear);        jMenuBar1.add(jMenu1);        setJMenuBar(jMenuBar1);        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());        getContentPane().setLayout(layout);        layout.setHorizontalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(layout.createSequentialGroup()                .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 828, javax.swing.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 1, Short.MAX_VALUE))        );        layout.setVerticalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)            .addComponent(jLayeredPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)        );        pack();    }// </editor-fold>                            private void jmOpean1ActionPerformed(java.awt.event.ActionEvent evt) {                                                 // TODO add your handling code here:        studentList.clear();                                                            // 清空线性表        JFileChooser filechooser = new JFileChooser();        if( filechooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION ){                File file = filechooser.getSelectedFile();                try{                    DataInputStream input = new DataInputStream                                    ( new FileInputStream(file) );                    while(true){                        String id = "" ;String name = "" ;int score=0;                        String s = input.readUTF();//                        System.out.println(s);                        if( s.length() == 0 ) continue;                        StringBuilder sb = new StringBuilder();                        sb.append(s); int cnt = 0 ;                        for( int i = 0 ; i < sb.length(); ++i ){                            char op = sb.charAt(i);                            if( op  == ‘,‘ ) { cnt++; continue ; }                            if( cnt == 0 ) id += op;                            else if( cnt == 1 ) name += op;                            else {                                score = score * 10 + (op-‘0‘);                            }                        }                        studentList.add( new Student(id,name,score) );                    }                }                catch( EOFException ex){                    System.out.println("All data read");                }                catch (IOException ex) {                    ex.printStackTrace();                }                updateDate();                                                                       //更新最高最低分,百分比                jLabelM.setText(maxScore+"");                jLabelm.setText(minScore+"");                jLabela.setText(averageScore+"");                jLabels0.setText(cnt[0]+"");                jLabels1.setText(cnt[1]+"");                jLabels2.setText(cnt[2]+"");                jLabels3.setText(cnt[3]+"");                jLabels4.setText(cnt[4]+"");                jLabelp0.setText(String.format("%.2f",percent[0]));                jLabelp1.setText(String.format("%.2f",percent[1]));                jLabelp2.setText(String.format("%.2f",percent[2]));                jLabelp3.setText(String.format("%.2f",percent[3]));                jLabelp4.setText(String.format("%.2f",percent[4]));                   jLabelfile.setText(file.getAbsolutePath()+",共"+ tot + "人" );                DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();                TableRowSorter<TableModel> sorter =                       new TableRowSorter<TableModel>(dtm);                this.jTable1.setRowSorter(sorter);                                while( dtm.getRowCount() != 0 ) {                                                   //清空jtable                    dtm.removeRow(0);                }                                for( int i = 0 ; i < studentList.size() ; ++i ) {                                   //studentList写入jTable                    Student tmp = (Student)studentList.get(i);                    Vector v = new Vector();                    v.add(tmp.get_id());v.add(tmp.get_name());v.add(tmp.get_score());                    dtm.addRow(v);                }        }    }                                            private void jmClearActionPerformed(java.awt.event.ActionEvent evt) {                                                DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();        while( dtm.getRowCount() != 0 ) {                                                   //清空jtable            dtm.removeRow(0);        }        jLabelM.setText(null);        jLabelm.setText(null);        jLabela.setText(null);        jLabels0.setText(null);        jLabels1.setText(null);        jLabels2.setText(null);        jLabels3.setText(null);        jLabels4.setText(null);        jLabelp0.setText(null);        jLabelp1.setText(null);        jLabelp2.setText(null);        jLabelp3.setText(null);        jLabelp4.setText(null);                 jLabelfile.setText(null);    }                                           private void jtfSearchActionPerformed(java.awt.event.ActionEvent evt) {                                                  String text = jtfSearch.getText();        TableRowSorter<TableModel> sorter =                       new TableRowSorter<TableModel>(jTable1.getModel());        this.jTable1.setRowSorter(sorter);           if( text.trim().length() == 0 )               sorter.setRowFilter(null);           else                sorter.setRowFilter(RowFilter.regexFilter(text));    }                                             private void jmOpean0ActionPerformed(java.awt.event.ActionEvent evt) {                                                         studentList.clear();                                                            // 清空线性表        JFileChooser filechooser = new JFileChooser();        if( filechooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION ){            try {                File file = filechooser.getSelectedFile();                                Scanner input  = new Scanner(file);                                while( input.hasNext() ) {                    String id = "" ;String name = "" ;int score=0;                    String s = input.nextLine();                    if( s.length() == 0 ) continue;                    StringBuilder sb = new StringBuilder();                    sb.append(s); int cnt = 0 ;                    for( int i = 0 ; i < sb.length(); ++i ){                        char op = sb.charAt(i);                        if( op  == ‘,‘ ) { cnt++; continue ; }                        if( cnt == 0 ) id += op;                        else if( cnt == 1 ) name += op;                        else {                            score = score * 10 + (op-‘0‘);                           }                    }                    studentList.add( new Student(id,name,score) );                }                                updateDate();                                                                       //更新最高最低分,百分比                jLabelM.setText(maxScore+"");                jLabelm.setText(minScore+"");                jLabela.setText(averageScore+"");                jLabels0.setText(cnt[0]+"");                jLabels1.setText(cnt[1]+"");                jLabels2.setText(cnt[2]+"");                jLabels3.setText(cnt[3]+"");                jLabels4.setText(cnt[4]+"");                jLabelp0.setText(String.format("%.2f",percent[0]));                jLabelp1.setText(String.format("%.2f",percent[1]));                jLabelp2.setText(String.format("%.2f",percent[2]));                jLabelp3.setText(String.format("%.2f",percent[3]));                jLabelp4.setText(String.format("%.2f",percent[4]));                         jLabelfile.setText(file.getAbsolutePath()+",共"+ tot + "人" );                                //                jTextField12 = new JTextField(""+maxcost);                input.close();                                DefaultTableModel dtm = (DefaultTableModel) jTable1.getModel();                TableRowSorter<TableModel> sorter =                       new TableRowSorter<TableModel>(dtm);                this.jTable1.setRowSorter(sorter);                                while( dtm.getRowCount() != 0 ) {                                                   //清空jtable                    dtm.removeRow(0);                }                                for( int i = 0 ; i < studentList.size() ; ++i ) {                                   //studentList写入jTable                    Student tmp = (Student)studentList.get(i);                    Vector v = new Vector();                    v.add(tmp.get_id());v.add(tmp.get_name());v.add(tmp.get_score());                    dtm.addRow(v);                }                           } catch (FileNotFoundException ex) {                Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);            }        }    }                                            private void jTextField11ActionPerformed(java.awt.event.ActionEvent evt) {                                                     // TODO add your handling code here:    }                                                private void jTextField10ActionPerformed(java.awt.event.ActionEvent evt) {                                                     // TODO add your handling code here:    }                                                private void jTextField9ActionPerformed(java.awt.event.ActionEvent evt) {                                                    // TODO add your handling code here:    }                                               private void jTextField8ActionPerformed(java.awt.event.ActionEvent evt) {                                                    // TODO add your handling code here:    }                                               private void jTextField7ActionPerformed(java.awt.event.ActionEvent evt) {                                                    // TODO add your handling code here:    }                                               private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                                 // TODO add your handling code here:        NewJFrame3 frame = new NewJFrame3(cnt);        frame.setVisible(true);        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);        frame.setSize(400, 400);        frame.setLocationRelativeTo(null);    }                                            private void jmSave0ActionPerformed(java.awt.event.ActionEvent evt) {                                                JFileChooser filechooser = new JFileChooser();        if( filechooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION ){            File file = filechooser.getSelectedFile();            try {                PrintWriter output = new PrintWriter(file);                for( int i = 0 ; i < studentList.size() ; ++i ) {                    Student tmp = (Student)studentList.get(i);                    output.println(tmp.get_id()+","+tmp.get_name()+","+tmp.get_score());                }                output.close();            } catch (FileNotFoundException ex) {                Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);            }        }    }                                           private void jbSearchActionPerformed(java.awt.event.ActionEvent evt) {                                                 String text = jtfSearch.getText();        TableRowSorter<TableModel> sorter =                       new TableRowSorter<TableModel>(jTable1.getModel());        this.jTable1.setRowSorter(sorter);           if( text.trim().length() == 0 )               sorter.setRowFilter(null);           else                sorter.setRowFilter(RowFilter.regexFilter(text));    }                                            private void jmSave1ActionPerformed(java.awt.event.ActionEvent evt) {                                                // TODO add your handling code here:        JFileChooser filechooser = new JFileChooser();        if( filechooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION ){            File file = filechooser.getSelectedFile();            try {                DataOutputStream output = new DataOutputStream                        ( new FileOutputStream(file));                for( int i = 0 ; i < studentList.size() ; ++i ) {                    Student tmp = (Student)studentList.get(i);                    output.writeUTF(tmp.get_String());                }                output.close();            } catch (FileNotFoundException ex) {                Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);            } catch (IOException ex) {                Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);            }        }    }                                           private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                                 // TODO add your handling code here:        NewJFrame5 frame = new NewJFrame5(percent);        frame.setVisible(true);        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);        frame.setSize(400, 400);        frame.setLocationRelativeTo(null);    }                                            /**     * @param args the command line arguments     */    public static void main(String args[]) {        /* Set the Nimbus look and feel */        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html          */        try {            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {                if ("Nimbus".equals(info.getName())) {                    javax.swing.UIManager.setLookAndFeel(info.getClassName());                    break;                }            }        } catch (ClassNotFoundException ex) {            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);        } catch (InstantiationException ex) {            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);        } catch (IllegalAccessException ex) {            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);        } catch (javax.swing.UnsupportedLookAndFeelException ex) {            java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);        }        //</editor-fold>        /* Create and display the form */        java.awt.EventQueue.invokeLater(new Runnable() {            public void run() {                new NewJFrame().setVisible(true);            }        });    }    // Variables declaration - do not modify                         private javax.swing.JButton jButton1;    private javax.swing.JButton jButton2;    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem2;    private javax.swing.JLabel jLabel11;    private javax.swing.JLabel jLabel12;    private javax.swing.JLabel jLabel13;    private javax.swing.JLabel jLabel14;    private javax.swing.JLabel jLabel15;    private javax.swing.JLabel jLabel16;    private javax.swing.JLabel jLabel17;    private javax.swing.JLabel jLabel18;    private javax.swing.JLabel jLabel19;    private javax.swing.JLabel jLabel20;    private javax.swing.JLabel jLabel21;    private javax.swing.JLabel jLabel22;    private javax.swing.JLabel jLabel23;    private javax.swing.JLabel jLabel25;    private javax.swing.JLabel jLabel26;    private javax.swing.JLabel jLabelM;    private javax.swing.JLabel jLabela;    private javax.swing.JLabel jLabelfile;    private javax.swing.JLabel jLabelm;    private javax.swing.JLabel jLabelp0;    private javax.swing.JLabel jLabelp1;    private javax.swing.JLabel jLabelp2;    private javax.swing.JLabel jLabelp3;    private javax.swing.JLabel jLabelp4;    private javax.swing.JLabel jLabels0;    private javax.swing.JLabel jLabels1;    private javax.swing.JLabel jLabels2;    private javax.swing.JLabel jLabels3;    private javax.swing.JLabel jLabels4;    private javax.swing.JLayeredPane jLayeredPane1;    private javax.swing.JMenu jMenu1;    private javax.swing.JMenu jMenu10;    private javax.swing.JMenu jMenu11;    private javax.swing.JMenu jMenu12;    private javax.swing.JMenu jMenu13;    private javax.swing.JMenu jMenu14;    private javax.swing.JMenu jMenu2;    private javax.swing.JMenu jMenu3;    private javax.swing.JMenu jMenu4;    private javax.swing.JMenu jMenu5;    private javax.swing.JMenu jMenu6;    private javax.swing.JMenu jMenu7;    private javax.swing.JMenu jMenu8;    private javax.swing.JMenu jMenu9;    private javax.swing.JMenuBar jMenuBar1;    private javax.swing.JMenuBar jMenuBar2;    private javax.swing.JMenuBar jMenuBar3;    private javax.swing.JMenuBar jMenuBar4;    private javax.swing.JMenuBar jMenuBar5;    private javax.swing.JMenuBar jMenuBar6;    private javax.swing.JMenuBar jMenuBar7;    private javax.swing.JPanel jPanel1;    private javax.swing.JPanel jPanel2;    private javax.swing.JPanel jPanel3;    private javax.swing.JPanel jPanel5;    private javax.swing.JScrollPane jScrollPane2;    private javax.swing.JPopupMenu.Separator jSeparator1;    private javax.swing.JPopupMenu.Separator jSeparator2;    private javax.swing.JSeparator jSeparator3;    private javax.swing.JSeparator jSeparator4;    private javax.swing.JTable jTable1;    private javax.swing.JTextField jTextField10;    private javax.swing.JTextField jTextField11;    private javax.swing.JTextField jTextField7;    private javax.swing.JTextField jTextField8;    private javax.swing.JTextField jTextField9;    private javax.swing.JButton jbSearch;    private javax.swing.JLabel jlbAnalysis;    private javax.swing.JLabel jlbAvgS;    private javax.swing.JLabel jlbFail;    private javax.swing.JLabel jlbGood;    private javax.swing.JLabel jlbMaxS;    private javax.swing.JLabel jlbMiddle;    private javax.swing.JLabel jlbMinS;    private javax.swing.JLabel jlbPass;    private javax.swing.JLabel jlbScore;    private javax.swing.JLabel jlbSearch;    private javax.swing.JLabel jlbWell;    private javax.swing.JMenuItem jmClear;    private javax.swing.JMenuItem jmOpean0;    private javax.swing.JMenuItem jmOpean1;    private javax.swing.JMenuItem jmSave0;    private javax.swing.JMenuItem jmSave1;    private javax.swing.JTextField jtfSearch;    // End of variables declaration                   }
View Code

 NewJFrame3

技术分享
package scoreaynalysissystem;import javax.swing.*;import java.awt.*;public class NewJFrame3 extends JFrame{    public NewJFrame3(int[] data){        add(new NewJFrame4(data));    }    public class NewJFrame4 extends JPanel{            private boolean filled = false;    private int[] data;    public NewJFrame4() {    }       public NewJFrame4(int[] data) {        this.data=http://www.mamicode.com/data;    }    public NewJFrame4(boolean filled){               this.filled=filled;    }    protected void paintComponent(Graphics g){        super.paintComponent(g);                int width = getWidth();        int height = getHeight();         int gap=20,aa=(int)(height*0.8/11),a2=(int)((0.8*width-6*gap)/5);                      g.drawRect((int)(0.1*width), (int)(0.1*height), (int)(0.8*width), (int)(0.8*height));               g.drawString(String.valueOf(data[0]),(int)(0.1*width+gap)+a2/2-1,(int)(height-0.1*height-aa*data[0])-5);               g.drawString("优秀",(int)(0.1*width+gap)+a2/2-10,(int)(height-0.1*height+12));               g.setColor(Color.black);               g.setColor(Color.green);               g.fillRect((int)(0.1*width+gap), (int)(height-0.1*height-aa*data[0]), a2, aa*data[0]);                                            g.setColor(Color.black);               g.drawString(String.valueOf(data[1]),(int)(0.1*width+2*gap+a2)+a2/2-1,(int)(height-0.1*height-aa*data[1])-5 );               g.drawString("良好",(int)(0.1*width+2*gap+a2)+a2/2-10,(int)(height-0.1*height+12));               g.setColor(Color.black);               g.setColor(Color.blue);               g.fillRect((int)(0.1*width+2*gap+a2), (int)(height-0.1*height-aa*data[1]),a2, aa*data[1]);                              g.setColor(Color.black);               g.drawString(String.valueOf(data[2]),(int)(0.1*width+3*gap+2*a2)+a2/2-1, (int)(height-0.1*height-aa*data[2])-5);               g.drawString("中等",(int)(0.1*width+3*gap+2*a2)+a2/2-10,(int)(height-0.1*height+12));               g.setColor(Color.black);               g.setColor(Color.orange);               g.fillRect((int)(0.1*width+3*gap+2*a2), (int)(height-0.1*height-aa*data[2]),a2, aa*data[2]);                              g.setColor(Color.black);               g.drawString(String.valueOf(data[3]),(int)(0.1*width+4*gap+3*a2)+a2/2-1, (int)(height-0.1*height-aa*data[3])-5);               g.drawString("及格",(int)(0.1*width+4*gap+3*a2)+a2/2-10,(int)(height-0.1*height+12));               g.setColor(Color.black);               g.setColor(Color.yellow);               g.fillRect((int)(0.1*width+4*gap+3*a2), (int)(height-0.1*height-aa*data[3]),a2, aa*data[3]);                              g.setColor(Color.black);               g.drawString(String.valueOf(data[4]),(int)(0.1*width+5*gap+4*a2)+a2/2-1, (int)(height-0.1*height-aa*data[4])-5);               g.drawString("不及格",(int)(0.1*width+5*gap+4*a2)+a2/2-15,(int)(height-0.1*height+12));               g.setColor(Color.black);               g.setColor(Color.red);               g.fillRect((int)(0.1*width+5*gap+4*a2), (int)(height-0.1*height-aa*data[4]),a2, aa*data[4]);                                      }                public boolean isFilled() {        return filled;    }    public void setFilled(boolean filled) {        this.filled = filled;         repaint();    }    public Dimension getPreferredSize(){        return new Dimension(80,80);    }}    }
View Code

NewJFrame5

技术分享
package scoreaynalysissystem;import java.awt.Color;import java.awt.Dimension;import java.awt.*;import javax.swing.*;public class NewJFrame5 extends JFrame{    public NewJFrame5(double[] data){        add(new NewJFrame6(data));    }    public class NewJFrame6 extends JPanel{            private boolean filled = false;    private double[] data;    public NewJFrame6() {    }       public NewJFrame6(double[] data) {        this.data=http://www.mamicode.com/data;    }    public NewJFrame6(boolean filled){               this.filled=filled;    }    protected void paintComponent(Graphics g){        super.paintComponent(g);                int width = getWidth()/2;        int height = getHeight()/2;         int radius = (int)(Math.min(getWidth(), getHeight())*0.4);        int d=2*radius;        int x = width-radius;        int y = height-radius;        String[] str = {String.format("%5.2f", data[0]),String.format("%5.2f", data[1]),String.format("%5.2f", data[2]),String.format("%5.2f", data[3]),        String.format("%5.2f", data[4])};                int[] a2={(int)(360*data[0]/100),(int)(360*data[1]/100),(int)(360*data[2]/100),(int)(360*data[3]/100),(int)(360*data[4]/100)};                        g.setColor(Color.green);        g.fillRect(5, 20, 10, 10);        g.fillArc(x, y,d,d, 0, a2[0]);                g.setColor(Color.blue);        g.fillRect(5, 40, 10, 10);        g.fillArc(x, y,d,d, a2[0], a2[1]);                g.setColor(Color.orange);         g.fillRect(5, 60, 10, 10);        g.fillArc(x, y,d,d, a2[0]+a2[1], a2[2]);                g.setColor(Color.yellow);        g.fillRect(5, 80, 10, 10);        g.fillArc(x, y,d,d, a2[0]+a2[1]+a2[2],a2[3]);                g.setColor(Color.red);        g.fillRect(5, 100, 10, 10);        g.fillArc(x, y,d,d,a2[0]+a2[1]+a2[2]+a2[3] ,a2[4]);                g.setColor(Color.black);        g.drawString("优秀"+str[0]+"%",  20, 30);        g.drawString("良好"+str[1]+"%",  20, 50);        g.drawString("中等"+str[2]+"%",  20, 70);        g.drawString("良好"+str[3]+"%",  20, 90);        g.drawString("不及格"+str[4]+"%",  20, 110);    }    public boolean isFilled() {        return filled;    }    public void setFilled(boolean filled) {        this.filled = filled;         repaint();    }    public Dimension getPreferredSize(){        return new Dimension(80,80);    }}    }
View Code

Student

技术分享
package scoreaynalysissystem;public class Student {    private String id ;    private String name;    private int score ;    Student (){    }    Student ( String id ,String name , int score ) {        this.id = id ; this.name = name ; this.score = score ;     }    public void set_id( String id ){        this.id = id ;    }    public void set_name( String name ){        this.name = name ;    }    public void set_score( int score ){        this.score = score ;    }    public String get_id(){        return this.id;    }    public String get_name(){        return this.name ;    }    public int get_score(){        return this.score;    }    public void show (){        System.out.println( this.id + "," + this.name + "," + this.score );    }    public String get_String (){        return this.id + "," + this.name + "," + this.score ;    }    public boolean eaquals( Student x ){        return ( this.score == x.score );    }    public int Compareable( Student x ){        if( this.score == x.score ) return 0 ;        else if( this.score > x.score ) return 1 ;        else return -1 ;    }}
View Code

 

Java综合性实验