Code Wed Apr 8 v2

First versions of code for Project 3

Main Tab - Version 1

//Main Tab
//Make objects, objects call methods

//Make an object instance

Button btn1;//declare the variable as global - btn is null

void setup(){
  size( 600, 600);
  colorMode(HSB, 360, 100, 100);
  // Button( float x, float y, float w, float h, String label  )
  btn1 = new Button( 20, 20, 100, 50, "Hello");  //initialize
}

void draw(){
  btn1.display();
  
  fill( color( 280, 100, 100));
  rect( 150, 50, 100 ,50);
  
 }
 
 void mouseClicked(){
   btn1.clicked( mouseX, mouseY);
 }

Button Class version 1

Does not include code for text label

Last updated

Was this helpful?