JLayeredPane versus Container layering
- by Gili
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.