FileDocCategorySizeDatePackage
event.javaAPI DocExample2872Thu Sep 28 13:09:02 BST 2000None

event

public class event extends Applet implements ActionListener

Fields Summary
private TextField
input
private int
choice
Constructors Summary
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent event)

      // The line below converts the 'string' in the textfield to
      // an integer...  
      choice = Integer.parseInt (input.getText());
      //  Now the choice has been entered, repaint the applet...
      // This will cause the routine 'paint' to be called.  You can insert all your code into
      // paint confident that it will  be run as a result of the repaint command.
      repaint();
   
public voidinit()

      Label menu1, menu2, menu3;
      // Create a menu using 'Labels'
      menu1 = new Label("Choice 1 = draw colour graph");
      menu2 = new Label("Choice 2 = draw colour pie chart");
      menu3 = new Label("Choice 3 = print colour table");
      add(menu1);
      add(menu2);
      add(menu3);
      input = new TextField(10);
      add (input);
      // addActionListener will cause the routine 'actionPerformed' to be invoked
      // when new data is entered in the textfield...
      input.addActionListener(this);
   
public voidpaint(java.awt.Graphics g)

	   // Here you can do something with the variable 'choice' confident that it has
	   // been set to some meaningful value in the routine 'actionPerformed'...
	   // Also check for errors in the input.  E.g. if the choice lies outside the
	   // acceptable range then tell the user using some appropriate message.
	   
	   // Parameters  for drawing pie chart
  	   double startAngle = 0.0;
      double arcAngle;
      int x = 10; // top left hand screen position (for the pie chart)
      int y = 100;
      int width = 200;  // The total size of the pie chart
      int height = 200;  
      arcAngle = 360.0 / 13.0;   //(360 degrees divided equally by the 13 available colours)
      
      // Parameters for drawing rectangle
      int rectangle_height = 15; 
      
      // Parameters for drawing table
      String colourString = " ";
      int string_height = 15;