Hey, sorry i can't help with your paint issue but i may be able to help with the random.
there are two variations of random. The first being
random(int x, int y)
and the second
random(int x)
the second returns a random number between 0 and x (exlusive)
hope this helps