java - Painting array of constant size? -
i having trouble doing simple, painting array of elements. here have paint method in class array: (xb , yb x , y values want increment make instances show in different locations).
public void paint(graphics pane) { private box[] boxes = new box[num_box]; for(int = 0; i<num_box; i++){ if (xb == 290){ xb = 0; yb = yb + 20; } boxes[i].paint(pane, xb, yb); xb = xb + 20; } and here have in box class being painted:
public class box { private final int width = 20; private final int height = 20; private boolean = true; public void paint(graphics pane, int x, int y) { pane.setcolor(color.black); pane.drawrect(x, y, width, height); pane.setcolor(color.gray); pane.fill3drect(x +2, y+2, width - 3, height - 3, up); } } every time run it, tells me there nullpointerexception @ boxes[i].paint(pane,xb,yb) line. doing wrong?
Comments
Post a Comment