import java.io.*;
class Student implements Serializable{
    String name; int note;
    Student(String name, int note){this.name = name;this.note = note;}
    public String toString(){
        return name+"   "+note;
    }
}
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Apl extends JFrame{
    JButton ad;
    JTextField tf[]= new JTextField[2];
    List lst;
   
    JPanel contr, plst;
   
    AdSt adSt;
    Student prs[]=new Student[0];
   
    Apl(int x, int y, int ln, int ht){
        this.setLayout(new BorderLayout());
        this.setBounds(x, y, ln, ht);
        this.setVisible(true);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       
        contr = new JPanel(new FlowLayout());
        plst = new JPanel(new FlowLayout());
       
        ad = new JButton("add");
        contr.add(ad);
        tf[0]= new JTextField("name?",10);
        tf[1]= new JTextField("note?",3);
        contr.add(tf[0]);
        contr.add(tf[1]);
        ad.addActionListener(adSt=new AdSt());
        add("North",contr);
       
        lst = new List(10);
        plst.add(lst);
        add("Center",plst);       
        revalidate();
    }
    class AdSt implements ActionListener{
        public void actionPerformed(ActionEvent e ){
            Student s;
            String n=tf[0].getText();
            int nt=Integer.parseInt(tf[1].getText());
            Student help[]= new Student[prs.length+1];
            System.arraycopy(prs, 0, help, 0, prs.length);
            help[help.length-1]= s=new Student(n,nt);
            prs=help; tf[0].setText("name?");tf[1].setText("note?");
            lst.add(""+s);
            revalidate();
        }
    }
    public static void main(String [] arg){
        Apl apl=new Apl(20,20,400,300);
    }
}
import javax.swing.*;

import java.awt.event.*;
import java.io.*;

public class Apl1 extends Apl{
    JButton load,save;  
   
    Apl1(){
        super(20,20,600,250);
        load = new JButton("load");
        load.addActionListener(new Load());
        contr.add(load);
        save = new JButton("save");
        save.addActionListener(new Save());
        contr.add(save);
        revalidate();
    }
    public static void main(String arg[]){
        new Apl1();     
    }
    class Save implements ActionListener  {
        public void actionPerformed(ActionEvent e ){
            ObjectOutputStream oos = null;
            try{
                oos = new ObjectOutputStream (
                    new FileOutputStream ("save.ser"));
                oos.writeObject(prs);
            }
            catch (IOException ex){
                System.out.println(ex);
            }
            try{
                if(oos!=null)oos.close();
            }
            catch (IOException ex){}
        }
    }
    class Load implements ActionListener  {
        public void actionPerformed(ActionEvent e ){
            ObjectInputStream ios = null;
            try{
                ios = new ObjectInputStream (new FileInputStream ("save.ser"));
                prs= (Student[])ios.readObject();
            }
            catch (Exception ex){
                tf[0].setText("Error");
            }
            try{
                if(ios!=null)ios.close();
            }
            catch (IOException ex){}
            lst. removeAll();
            for(int i=0;i<prs.length;i++){
                lst.add(""+prs[i]);
            }           
        }       
    }
}
import java.awt.event.*;
public class Apl2 extends Apl1{
    public static void main(String [] arg){
        new Apl2();      
    }
    Apl2(){
        tf[0].addMouseListener(new Sel0());
        tf[1].addMouseListener(new Sel1());
    }
    class Sel0 extends MouseAdapter{
        public void mouseClicked(MouseEvent e){
            tf[0].setText("");
        }
    }
    class Sel1 extends MouseAdapter{
        public void mouseClicked(MouseEvent e){
            tf[1].setText("");
        }
    }
}