import java.awt.*;
import java.io.*;
/**
making or revising java gui applications using this class

- define each control in section "Controls"
- define functions in "handleEvent" method for action controls
   do not define functions for textFields or labels
- put screen coordinates in the constructor
   this is the most difficult part
   two methods possible:
   absolute positioning
      absolute positioning uses pixel x,y, width,height
   use "Screen" to layout screen
      modify XXX.java output
*/
public class AbFab extends Frame 
   {  
   private boolean inAnApplet = true;
   // Controls:
   Component[] comp = new Component[64];
   List[] list = new List[32];
   Choice[] choice = new Choice[32];
   //-----------------handleEvent method-------------------------
   // every control should be the target of a function call
   // if add or remove gui controls
   //    'if e.target == NEWCNTRL...return (funcs_NEWCNTRL(e))'
   //    then, add the control's code in your new function 
   //    'funcs_NEWCNTRL'
   public boolean handleEvent(Event e)
      {
      if (e.target == comp[0])
         return (funcs_0(e));
      if (e.id == Event.WINDOW_DESTROY)
         {
         if (inAnApplet)
            dispose();
         else
            System.exit(0);
         }
      return super.handleEvent(e);
      }
   //------------------Controls------------------------------------
   // all controls that do something
   //    are called by a function listed in handleEvent
   //    each function in handleEvent should be here
   //       even if it does nothing
   //       example of a control function that does nothing:
   //       boolean funcs_button_nothing01(Event e){return true;}
   //
   public boolean funcs_0(Event e)
      {
      return true;
      }
   public boolean funcs_2(Event e)
      // sometimes other control will manipulate list control
      //    list control should avoid using e.arg in such case
      //    because other control has different e.arg
      {
      switch(e.id)
         {
         case Event.ACTION_EVENT:            //double-click
            System.out.println("Hello hello");
            break;
         case Event.LIST_SELECT:
            //int i = list01.getSelectedIndex();
            //String line=list01.getItem(i);
            //list_file(PrintDir+"/"+line);
            //file_contents_label.setText("list for "+line);
            break;
         case Event.LIST_DESELECT:
         default:
            break;
         }
      return true;
      }
   public boolean funcs_button_cancel(Event e)
      {
      // if dirty (ie changes made)
      //    query if user really wants to quit
      if (inAnApplet)
         dispose();
      else
         System.exit(0);
      return false;
      }  
   //------------------constructor----------------------------------
   // lays out the controls on the main panel
   // performs any initialization 
   //    like loading lists
   //
   public AbFab(String title) 
      {
      super(title);
      new XXX(this, comp);
      }
   public static void main(String[] args) 
      {
      AbFab f = new AbFab("title");
      f.inAnApplet = false;
//      f.resize(400,300);
//      f.pack();
      f.show();
      }
   }
