/[classpath]/classpath/java/awt/Container.java
ViewVC logotype

Diff of /classpath/java/awt/Container.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.37.2.12 by gnu_andrew, Sun Aug 7 18:34:10 2005 UTC revision 1.37.2.13 by gnu_andrew, Tue Aug 16 16:22:37 2005 UTC
# Line 43  import java.awt.event.ContainerEvent; Line 43  import java.awt.event.ContainerEvent;
43  import java.awt.event.ContainerListener;  import java.awt.event.ContainerListener;
44  import java.awt.event.KeyEvent;  import java.awt.event.KeyEvent;
45  import java.awt.event.MouseEvent;  import java.awt.event.MouseEvent;
46    import java.awt.peer.ComponentPeer;
47  import java.awt.peer.ContainerPeer;  import java.awt.peer.ContainerPeer;
48  import java.awt.peer.LightweightPeer;  import java.awt.peer.LightweightPeer;
49  import java.beans.PropertyChangeListener;  import java.beans.PropertyChangeListener;
# Line 342  public class Container extends Component Line 343  public class Container extends Component
343            comp.parent.remove(comp);            comp.parent.remove(comp);
344          comp.parent = this;          comp.parent = this;
345    
         // Notify the component that it has a new parent.  
         comp.addNotify();  
   
346          if (peer != null)          if (peer != null)
347            {            {
348                // Notify the component that it has a new parent.
349                comp.addNotify();
350    
351              if (comp.isLightweight ())              if (comp.isLightweight ())
352                {                {
353                  enableEvents (comp.eventMask);                  enableEvents (comp.eventMask);
# Line 759  public class Container extends Component Line 760  public class Container extends Component
760    {    {
761      if (!isShowing())      if (!isShowing())
762        return;        return;
763      // Paint self first.  
     super.paint(g);  
764      // Visit heavyweights as well, in case they were      // Visit heavyweights as well, in case they were
765      // erased when we cleared the background for this container.      // erased when we cleared the background for this container.
766      visitChildren(g, GfxPaintVisitor.INSTANCE, false);      visitChildren(g, GfxPaintVisitor.INSTANCE, false);
# Line 778  public class Container extends Component Line 778  public class Container extends Component
778     * @specnote The specification suggests that this method forwards the     * @specnote The specification suggests that this method forwards the
779     *           update() call to all its lightweight children. Tests show     *           update() call to all its lightweight children. Tests show
780     *           that this is not done either in the JDK. The exact behaviour     *           that this is not done either in the JDK. The exact behaviour
781     *           seems to be that top-level container call super.update()     *           seems to be that the background is cleared in heavyweight
782     *           (causing the background to be cleared), and all other containers     *           Containers, and all other containers
783     *           directly call paint(), causing the (lightweight) children to     *           directly call paint(), causing the (lightweight) children to
784     *           be painted.     *           be painted.
785     */     */
786    public void update(Graphics g)    public void update(Graphics g)
787    {    {
788      if (getParent() == null)      // It seems that the JDK clears the background of containers like Panel
789        super.update(g);      // and Window (within this method) but not of 'plain' Containers or
790            // JComponents. This could
791        // lead to the assumption that it only clears heavyweight containers.
792        // However that is not quite true. In a test with a custom Container
793        // that overrides isLightweight() to return false, the background is
794        // also not cleared. So we do a check on !(peer instanceof LightweightPeer)
795        // instead.
796        ComponentPeer p = peer;
797        if (p != null && !(p instanceof LightweightPeer))
798          g.clearRect(0, 0, getWidth(), getHeight());
799    
800      paint(g);      paint(g);
801    }    }
802    

Legend:
Removed from v.1.37.2.12  
changed lines
  Added in v.1.37.2.13

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26