• 成绩录入


    package HelloJava;  
    import java.awt.BorderLayout;  
    import java.awt.Container;  
    import java.awt.GridLayout;  
    import java.awt.event.*;  
    import java.security.cert.CollectionCertStoreParameters;  
      
    import javax.swing.*;  
    import javax.swing.text.Document;  
    import java.util.*;  
      
    public class Myb extends JFrame implements ActionListener {  
         JLabel interestLabel = new JLabel("姓名");   
         JTextField text = new  JTextField();     
         JLabel interestLabe2 = new JLabel("成绩");   
         JTextField text1 = new  JTextField();  
         JButton button = new JButton ("确认");  
        JTextArea textArea = new JTextArea(5,25);  
      
        List<paixun> list = new ArrayList<paixun>();  
         Myb()  
         {  
              super("work");  
              Container contentPane = getContentPane();         
              JPanel northPanel = new JPanel();  
              northPanel.setLayout(new GridLayout(2,1));    
              Box box1 = Box.createHorizontalBox();  
              Box box2 = Box.createHorizontalBox();            
              box1.add(Box.createHorizontalStrut(3));  
              box1.add(interestLabel );  
              text.setColumns(5);    
              box1.add(text );  
              box1.add(interestLabe2 );  
              box1.add(text1);  
              button.addActionListener(new ActionListener() {             
                @Override  
                public void actionPerformed(ActionEvent e) {  
                      
                    // TODO 自动生成的方法存根  
                    textArea.setText("");  
                    list.add(new paixun(text.getText().toString(),Double.parseDouble(text1.getText().toString())));  
                     Collections.sort(list);  
                    for(paixun p:list)  
                      textArea.setText(textArea.getText()+"
    "+p.name +"	"+p.Grade+ "分");   
                       
                    text.setText("");  
                    text1.setText("");  
                }  
            });   
              box1.add(button);          
              northPanel.add(box1);          
              contentPane.add(northPanel, BorderLayout.NORTH);             
              JScrollPane scrollPane = new JScrollPane(textArea);  
              contentPane.add(scrollPane, BorderLayout.CENTER);  
              setVisible(true);  
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
              setSize(400, 300);  
         }   
         public void actionPerformed(ActionEvent e)           
              {    
                  return;   
              }  
         class paixun implements Comparable<paixun>{  
             public String name;  
             public Double Grade;  
             paixun(String name,Double Grade){  
                 this.name=name;  
                 this.Grade=Grade;  
             }  
            @Override  
            public int compareTo(paixun o) {  
                // TODO 自动生成的方法存根  
                return Grade.compareTo(o.Grade);  
            }  
         
         }  
         public static void main(String args[])  
         {  
              new Myb();  
         }  
    }  
    

      

  • 相关阅读:
    composer在phpstorm中安装代码库
    [C#]WinForm 中 comboBox控件之数据绑定
    【建模+强连通分量】POJ1904 King's Quest
    【构造】UVa 11387 The 3-Regular Graph
    【环套树+树形dp】Bzoj1040 [ZJOI2008] 骑士
    【强连通分量+spfa】Bzoj1179 Apio2009 Atm
    【树形dp】Bzoj3391 [Usaco2004 Dec]Tree Cutting网络破坏
    【dfs+连通分量】Bzoj1123 POI2008 BLO
    【强连通分量+概率】Bzoj2438 杀人游戏
    【强连通分量】Bzoj1194 HNOI2006 潘多拉的盒子
  • 原文地址:https://www.cnblogs.com/spsglz/p/8017880.html
Copyright © 2020-2023  润新知