Z-order on Java Swing components
I've been looking all over for some mention of this, but I cannot find any substantial information on it. Is there a way to change the z-order of Swing compon开发者_开发知识库ents, or at least change the draw order so that they appear to be above others?
You are looking for setComponentZOrder
Here's an example.
If you want to overlay components over other components, you should use JLayeredPane, which will let you add components to specific layers. This is precisely what's used for things like tooltips and drag-and-drop operations.
Here's a tutorial for it as well.
Look at the setComponentZOrder(...) method of the Container class.
You can also check out the Overlap Layout which has a brief description on how ZOrder works.
精彩评论