What is this line of code supposed to do?
if(!initialoval)gm.drawOval(mainX,mainY,width,height);initialoval=true;
Why hide the statements like that?
Try debugging the code by adding a println statement to the paint method to see when it is called.
The drawing code needs to be called from the paint() method.
Another test. Change the color used in the paint() method:
gm.setColor(Color.magenta); //<<<<<<<<<maincolor);
Then draw an oval and slowly drag the side to change the size. Notice the color of oval changes to magenta and then the oval disappears.