Q:

How to draw a box in java inside which various shapes can be drawn? 

I am using paint method to draw shapes .  But I want those shapes to appear inside a box whose by deafault colour is white .  How do i do it? 

A:

check the Sun/Oracle tutorial on this very subject.