How do you draw a rectangle around a whole bunch of components?

Also, how do you draw a polygon?

I tried creating a method called paint but it seems to be overriding another paint method and...