I can't figure out how to make this array compatible with my Button class

please format code with </> button * homework policy * asking questions

I’m trying to create a randomly generated chord progression program but I haven’t even reached that part yet, I’m stuck on making an array with my button class. The error message is “Type mismatch: cannot convert from sketch_221023a.Button to int,” which doesn’t make sense because I’ve followed 3 tutorials on how to implement arrays into classes and I don’t see what’s wrong. (please excuse some redundancies and messy attempted solutions, I’ve been trying to bugfix this for the past hour)

//library imports
import wellen.*;
//tips for using wellen
//Tone.note_on(x,y) |  creates a note, x being the pitch and y being the velocity. Pitch is between 0-127. Velocity is 0-100.
//Tone.note_off(x,y) |  will turn off matching tones
//Tone.is_playing() ? x : y  |  detects if a note is playing, will give x if yes or y if no
//Scale.HALF_TONE, this defines the scale for an int, half tone is the scale of all tones
//Scale.get_note(x, y, z)  |  x is the scale used, y is the root note, z is the steps up from the root note in accordance with the scale
Button resetbutton;
int screenx = 800;
int screeny = 800;
//screenx and y because size doesn't take floats
int sy;
int sx;
int numButton = 1;
int buttonWidth;
int buttonHeight;
String[] text = {"1","2","3","4"};
int[] buttons = new int[50];
int colorR;
int colorG;
int colorB;
Button ba;

void settings() {
  sx = screenx;
  sy = screeny;
  for (int i = 0; i < 4; i ++)
  {
      buttons[i] = new Button(0+(sx/numbutton), 0+(sy/numbutton), buttonWidth, buttonHeight, text, buttonColor, colorR, colorG, colorB);
      numButton = numButton++;
  }
  size(screenx, screeny);
}

void setup() {
}

void draw() {
  ba = new Button(0+(sx/numButton), 0+(sy/numButton), buttonWidth, buttonHeight, "hi", colorR, colorG, colorB);
  background(255);
  fill(0);
  println(screenx+ screeny);

  // buttons.update
  //  buttons.render
}

void mousePressed() {
  Tone.note_on(50, 100);
}

here is the class code

class Button
{
  PVector Pos = new PVector(0, 0);
  float Width = 0;
  float Height = 0;
  color Color;
  String Text;
  boolean Pressed = false;
  boolean Clicked = false;
  // Constructor to create button
  Button(int x, int y, int w, int h, String t, int r, int g, int b)
  {
    Pos.x = x;
    Pos.y = y;
    Width = w;
    Height = h;
    Color = color(r, g, b);
    Text = t;
  }
  void update() //must be place in draw in order to work
  {
    if (mousePressed == true && mouseButton == LEFT && Pressed == false)
    {
      Pressed = true;
      if (mouseX >= Pos.x && mouseX <= Pos.x+Width && mouseY >= Pos.y && mouseY <= Pos.y+Height)
      {
        Clicked = true;
      }
    } else {
      Clicked = false;
      Pressed = false;
    }
  }
  void render() //must be place in draw to render on screen
  {
    fill(Color);
    rect(Pos.x, Pos.y, Width, Height);

    fill(0);
    textAlign(CENTER, CENTER);
    text(Text, Pos.x+(Width/2), Pos.y+(Height/2));
  }
  boolean IsClicked()//used in if statements to check if button has been clicked
  {
    return Clicked;
  }
}

if anybody can help I’d super super appreciate it!

a little update I added this code

Button buttons = new Button[50];

it did not change the result

Hi there Dartbray, you’re close with your little update.

The problem is that you declare it to be of type Button (singular), yet you initialize it with new Button[50] (array). Simply change it into:

Button[] buttons = new Button[50];