You should never mix heavyweight and lightweight
components; a heavyweight component will always hide all lightweight
components that occupy the same display area. If your program creates, for
example, an instance of the JPopupMenu
class, you will not see
that instance if it lies in an area covered by a heavyweight component,
such an instance of the Canvas
class.
Accordingly, you should do your drawing and text layout on instances of
the JComponent
class, rather than of the Canvas
class, even
though the name might pull you toward the Canvas
class.