0

Hey guys

I'm using JLayeredPane because i want three distinct layers in my program. terrain, buildings and then characters.

I thought that JLayeredPane was easily the best choice for this context. The problem is, I have only seen people *adding* components to their layers. I need to do my own painting, but I don't know how to specify which layer i want to paint to.

Something I just thought of now was perhaps getting the graphics context for a specific frame and painting to that? How would i do that?

3
Contributors
3
Replies
5
Views
8 Years
Discussion Span
Last Post by JamesCherrill
0

so i should use multiple glass panes and then paint the various layers to a specific glasspane?

0

Small error in your thinking: you don't paint a layer - you just paint the things in the JLayeredPane and the "layers" determine which things get painted on top of which.
So, you can simply add three things (eg JLabels) to the JLayeredPane, setting their depths appropriately, then override the paint(...) method for each of the three things you added. You will probably also want to take a quick look at how transparency works in Swing (Google) if you want lower things to show thru the gaps in higher things.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.