try to add LayoutManager to your panel :) GridLayout will be good for this example.
By the way...u dont have to use "this" into Painting class...Methods like setSize and others refer to your class...