macc88392 macc88392 - 6 months ago 11
Java Question

Change color of rectangle in grid

[okpojiojiojpibgvuihuoihiubiuhgvtyghkjxeruxcjvtm]

Answer

try

for(Lifeform[] n : Life){
    for(Lifeform lf : n){
        g.setColor(lf.getColor());
        g.fillRect((int)lf.getX(), (int)lf.getY(), (int)lf.getWidth(), (int)lf.getHeight());
    }
}

in your paintComponent method

Comments