// Title	: Abdulla							
// Programmer	: Abdulla Al-mutawa					        
// Date Written	: 10/19/00					
// Purpose	: For this assignment, we will need to implement 
//              : a user Interface Class that allows the user to 
//              : enter a number , and to assemble a series of these 
//              : numbers together then display this assemblage on the
//              : user interface . When the user indicates completion 
//              : the Interface Class will send to an instance of the 
//              : Sort Class (the other class which we create) the input 
//              : string the user has entered. 



// Imported libraries

  import java.awt.*;
  import java.applet.Applet;
  import java.awt.event.*;
               

// Main class 
    public class Abdulla extends Applet implements ActionListener
      
    {  
//create a variables list 
     
          
     private Button add_button          = new Button ("Add");
     private Button done_button         = new Button ("Done");
     private Button clear_button        = new Button ("Clear");
     
     private TextField one_field        = new TextField (12);
     private TextField two_field        = new TextField (12);
     private TextField three_field      = new TextField (12);
     private TextField four_field       = new TextField (12);
  
     private Label onelabel             = new Label ("Enter any number then press Add");
     private Label twolabel             = new Label ("Press Done to sort the # which u have entered");
     private Label threelabel           = new Label ("The # which u have entered");
     private Label fourlabel            = new Label ("# sorted Ascending");
     private Label fivelabel            = new Label ("# sorted Descending");
     
     private Panel a_panel              = new Panel ();
     private Panel b_panel              = new Panel ();
    
    String one    = " ";
    String two    = " " ;
    String three  = " "; 
    String four   = " ";
     
// init
    public void init()        
     
       {
//add list 
        
        setLayout(new BorderLayout());
        add("South",a_panel);
        a_panel.add(add_button);
        add_button.addActionListener(this);
        a_panel.add(done_button);
        done_button.addActionListener(this);
        a_panel.add(clear_button);
        clear_button.addActionListener(this);
       
        b_panel.setLayout(new GridLayout(9,1));
        add("North",b_panel);
        b_panel.add(onelabel);
        b_panel.add(twolabel);
        b_panel.add(one_field);
        one_field.addActionListener(this);
        b_panel.add(threelabel);
        b_panel.add(two_field );
        two_field.addActionListener(this);
        two_field.setBackground (Color.gray);
        b_panel.add(fourlabel);
        b_panel.add(three_field);
        three_field.addActionListener(this);
        three_field.setBackground (Color.gray);
        b_panel.add(fivelabel);
        b_panel.add(four_field);
        four_field.addActionListener(this);
        four_field.setBackground (Color.gray);
    



}//end init

// actionPerformed
    public void actionPerformed(ActionEvent event) 
  
    {
   
      if   (event.getSource() == add_button) 
           
         {
            one = one_field.getText();
            two = two + one+"," ;  
            two_field.setText(two);
            one_field.setText(" "); 
         } 
   
                 
      if     (event.getSource() == done_button)
       
             {                  
               Abdulla1 done   = new Abdulla1 (two);
               three        = done.ascending();
               four         = done.descending();
               three_field.setText(three);
               four_field.setText(four);

             } 

                
    if      (event.getSource() == clear_button)  
               
           {
             one_field.setText(" ");
             two_field.setText(" ");
             three_field.setText(" ");
             four_field.setText(" ");
          
             one     =(" ");
             two     =(" ");
             three   =(" ");
             four    =(" ");

           }



}  //end actionPerformed
     
}//end class Abdulla
