Drawing simple shapes by mouse dragging
Just a few thoughts...

You are using x and y coordinates. Why not take advantage of the Point class? The MouseEvent class has methods that return Point objects, and it would probably make your code more readable. x1 and y1 don't mean anything to me, but you could probably give meaningful names to the points represented by (x1, y1) and (x2, y2).

The use of magic numbers (you storing 2 and 3 into SWITCH, for example) is a poor practice. Use constant ints or (as Landei suggested in the comments) an enum. It will allow you to improve the readable and understandability of the code - at a first read-through, I didn't get what you were doing.

As per Java standards, a class name should begin with a capital letter. Your class is currently called r. You should give it a meaningful name. You might also want to look into other Java standards for code formatting in terms of brace placement, indentation, and so forth. To me, your code is just plain hard to read because of formatting.

Rather than if and switch/case statements, consider leveraging polymorphism in order to draw different shapes. Move the logic to draw different shapes into concrete subclasses, while perhaps maintaining common logic in a superclass.