Maybe you wanna call setOpacity() before you paint the rect.