JLayeredPane versus Container layering
Posted
by
Gili
on Stack Overflow
See other posts from Stack Overflow
or by Gili
Published on 2011-01-13T15:41:32Z
Indexed on
2011/01/13
20:53 UTC
Read the original article
Hit count: 322
JLayeredPane allows one to stack multiple Components on top of one another using JLayeredPane.add(Component, Integer). Components in higher "layers" display on top of Components in lower "layers".
Container.add(Component, int) provides a similar mechanism whereby Components with lower indexes display on top of Components with higher indexes.
Please note that the first mechanism uses Integer and the second mechanism uses int. Also, one renders high values on top of low ones, and the other does the opposite. Do not mix the two :)
My question is: what's the point of using JLayeredPane when Container already provides the same mechanism? Does one layer components better than the another?
UPDATE: There is also Container.setComponentZOrder(Component, int) to consider.
© Stack Overflow or respective owner