//import coco.*;
import java.io.*;
import java.awt.*;

/*page designers may write codes such as this*/
class GenerateExampleCocoPage{
  public static void main(String[] argv){
    /*tabula rasa*/
    CocoPage cp=new CocoPage();

    /*add a label showing static text*/
    cp.setLayout(new FlowLayout());
    cp.add(new Label("This is an example coco page."));

    /*add a coco component*/
    CocoCounter cc=new CocoCounter(); //of type CocoCounter
    cc.setCocoId("CNTR01"); //called CNTR01
    cc.setState("1"); //with an initial state of "1"
    cp.add(cc); //to the page
    
    /*add a submit button; actionlistener remains unset until page is
      downloaded*/
    CocoSubmitButton b=new CocoSubmitButton();
    b.setLabel("Increment"); //look
    b.setCocoAddressee("CNTR01"); //address the counter
    b.setCocoRequest("INC"); //only accepted by the counter
    cp.add(b); //to the page

    /*write the page to a file; designer will upload this file to the
      coco page server*/
    try{
      cp.dump("justdown.cjd");
    }catch(IOException x){
      System.out.println("Error dumping generated page.\n"+x.toString());
    }
  }
}
