How can I add depth to my AWT components to allow components to overlap each other when needed like JLayeredPane in Swing components?

Sandip Chitale

You were always able to overlap AWT components. (You just needed to click your heels...)

You can manage the overlapped components on the basis of 'layers' by adapting the code from JLayeredPane. Only thing you can not do is to have transparent components.

[FAQ Manager Note] If the components are heavyweight, like the basic AWT components, they can only be opaque rectangles. However, if you create your own lightweight components (which is what Swing does...) you can have overlapping non-opaque components.

Note that creating overlapping components means that you're not using a layout manager. Unless you're doing something special, I strongly recommend you always use layout managers.

I would recommend that you read my layout manager tutorial at for more details on layout managers

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.