JAVA   23
ICanCount1
Guest on 9th February 2023 03:03:51 AM


  1. import objectdraw.*;
  2. import java.awt.*;
  3.  
  4.     // A program to count as high as you can click.
  5. public class ICanCount extends WindowController {
  6.  
  7.                                 // Where to display the instructions
  8.     private static final Location INSTR_POS = new Location( 20, 100);
  9.  
  10.     private int theCount = 0;   // how high we have counted
  11.  
  12.         // Create the Text to display the current count
  13.     public void begin() {
  14.         new Text( "Click to make me count", INSTR_POS, canvas );
  15.     }
  16.  
  17.         // Increase the count with each click
  18.     public void onMouseClick(Location point) {
  19.         theCount = theCount + 1;
  20.         System.out.println( theCount );
  21.     }
  22. }

Raw Paste

Login or Register to edit or fork this paste. It's free.