Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Answering my own question:</p> <p><a href="http://download.oracle.com/javase/6/docs/api/java/awt/Container.html#add%28java.awt.Component,%20int%29">Container.add(Component, int)</a> and <a href="http://download.oracle.com/javase/6/docs/api/java/awt/Container.html#setComponentZOrder%28java.awt.Component,%20int%29">Container.setComponentZOrder(Component, int)</a> are virtually identical. The former invokes removeNotify() while the latter does not (for performance reasons).</p> <p>Container-layering only works if <a href="http://download.oracle.com/javase/6/docs/api/javax/swing/JComponent.html#isOptimizedDrawingEnabled%28%29http://download.oracle.com/javase/6/docs/api/javax/swing/JLayeredPane.html#isOptimizedDrawingEnabled%28%29">JComponent.isOptimizedDrawingEnabled()</a> returns false. One implementation that just-so-happens to return false is... you guessed it: <a href="http://download.oracle.com/javase/6/docs/api/javax/swing/JLayeredPane.html">JLayeredPane</a></p> <p>Using Container-layering is discouraged because it can have <a href="http://download.oracle.com/javase/6/docs/api/javax/swing/JLayeredPane.html">unexpected side-effects</a>.</p> <p>Finally, it is worth noting that while Container declares <a href="http://download.oracle.com/javase/6/docs/api/java/awt/Container.html#add%28java.awt.Component,%20int%29">add(Component, int)</a> it doesn't actually paint layered components properly. <a href="http://download.oracle.com/javase/6/docs/api/javax/swing/JComponent.html">JComponent</a> and its subclasses do.</p> <p>Another interesting find: never invoke repaint() on a child of JLayeredPane. This will cause the component to paint itself on top regardless of its z-order. You should only invoke repaint() on the JLayeredPane itself.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload