You should give more information (code!). Is the rectangle inside any Layout?