ArrayList syntax problem
in
Programming Questions
•
3 years ago
Hi folks,
Trying to get on top of ArrayLists but I keep on hitting errors I can't make sense of. When I try and run it I get the following error: "The method add(Component) in the type container is not applicable for the arguments (ArrayList.FadingLine)".
I've looked through the reference and searched this forum and the old one, to no avail. Any suggestions for what I'm doing wrong or further reading would be appreciated!
- ArrayList list1;
- void setup() {
- size(500, 500);
- background(255);
- smooth();
- list1 = new ArrayList();
- list1.add(new FadingLine(random(0, width), random(0, width), random(0, width), random(0, width), 255)); //highlighted as error
- }
- void draw(){
- background(255);
- for(int i=1; i<list1.size(); i++){
- FadingLine lines = (FadingLine) list1.get(i);
- lines.drawLine();
- lines.update();
- }
- list1.add(new FadingLine(random(0, width), random(0, width), random(0, width), random(0, width), 255));
- }
- class FadingLine {
- float x1, y1, x2, y2, trans;
- FadingLine(float X1, float Y1, float X2, float Y2, float TRANS) {
- x1= X1;
- x2= X2;
- y1= Y1;
- y2= Y2;
- trans= TRANS;
- }
- void drawLine() {
- stroke (70, trans);
- line(x1, y1, x2, y2);
- }
- void update(){
- trans--;
- }
- }
Kyle
1