jdk/src/share/classes/javax/swing/JLayeredPane.java
changeset 1301 15e81207e1f2
parent 2 90ce3da70b43
child 1639 a97859015238
equal deleted inserted replaced
1300:e7bbe37ce03a 1301:15e81207e1f2
   189     }
   189     }
   190 
   190 
   191     private void validateOptimizedDrawing() {
   191     private void validateOptimizedDrawing() {
   192         boolean layeredComponentFound = false;
   192         boolean layeredComponentFound = false;
   193         synchronized(getTreeLock()) {
   193         synchronized(getTreeLock()) {
   194             Integer layer = null;
   194             Integer layer;
   195 
   195 
   196             for (Component c : getComponents()) {
   196             for (Component c : getComponents()) {
   197                 layer = null;
   197                 layer = null;
   198                 if(c instanceof JInternalFrame || (c instanceof JComponent &&
   198                 if(c instanceof JInternalFrame || (c instanceof JComponent &&
   199                          (layer = (Integer)((JComponent)c).getClientProperty(
   199                          (layer = (Integer)((JComponent)c).getClientProperty(
   211         else
   211         else
   212             optimizedDrawingPossible = true;
   212             optimizedDrawingPossible = true;
   213     }
   213     }
   214 
   214 
   215     protected void addImpl(Component comp, Object constraints, int index) {
   215     protected void addImpl(Component comp, Object constraints, int index) {
   216         int layer = DEFAULT_LAYER.intValue();
   216         int layer;
   217         int pos;
   217         int pos;
   218 
   218 
   219         if(constraints instanceof Integer) {
   219         if(constraints instanceof Integer) {
   220             layer = ((Integer)constraints).intValue();
   220             layer = ((Integer)constraints).intValue();
   221             setLayer(comp, layer);
   221             setLayer(comp, layer);
   362 
   362 
   363         /// MAKE SURE THIS AND putLayer(JComponent c, int layer) are SYNCED
   363         /// MAKE SURE THIS AND putLayer(JComponent c, int layer) are SYNCED
   364         if(c instanceof JComponent)
   364         if(c instanceof JComponent)
   365             ((JComponent)c).putClientProperty(LAYER_PROPERTY, layerObj);
   365             ((JComponent)c).putClientProperty(LAYER_PROPERTY, layerObj);
   366         else
   366         else
   367             getComponentToLayer().put((Component)c, layerObj);
   367             getComponentToLayer().put(c, layerObj);
   368 
   368 
   369         if(c.getParent() == null || c.getParent() != this) {
   369         if(c.getParent() == null || c.getParent() != this) {
   370             repaint(c.getBounds());
   370             repaint(c.getBounds());
   371             return;
   371             return;
   372         }
   372         }
   386     public int getLayer(Component c) {
   386     public int getLayer(Component c) {
   387         Integer i;
   387         Integer i;
   388         if(c instanceof JComponent)
   388         if(c instanceof JComponent)
   389             i = (Integer)((JComponent)c).getClientProperty(LAYER_PROPERTY);
   389             i = (Integer)((JComponent)c).getClientProperty(LAYER_PROPERTY);
   390         else
   390         else
   391             i = (Integer)getComponentToLayer().get((Component)c);
   391             i = getComponentToLayer().get(c);
   392 
   392 
   393         if(i == null)
   393         if(i == null)
   394             return DEFAULT_LAYER.intValue();
   394             return DEFAULT_LAYER.intValue();
   395         return i.intValue();
   395         return i.intValue();
   396     }
   396     }
   463      *         count of components at that layer, minus 1
   463      *         count of components at that layer, minus 1
   464      *
   464      *
   465      * @see #getComponentCountInLayer
   465      * @see #getComponentCountInLayer
   466      */
   466      */
   467     public int getPosition(Component c) {
   467     public int getPosition(Component c) {
   468         int i, count, startLayer, curLayer, startLocation, pos = 0;
   468         int i, startLayer, curLayer, startLocation, pos = 0;
   469 
   469 
   470         count = getComponentCount();
   470         getComponentCount();
   471         startLocation = getIndexOf(c);
   471         startLocation = getIndexOf(c);
   472 
   472 
   473         if(startLocation == -1)
   473         if(startLocation == -1)
   474             return -1;
   474             return -1;
   475 
   475