Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4141321

Multiple paint backgrounds (Possible cause of Bug 4099219?)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 1.2.0
    • Fix Version/s: None
    • Component/s: client-libs
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description



      Name: bk70084 Date: 05/22/98


      I'm reading over the awt source in jdk1.1.6 and came across this
      oddity:

      public abstract class Container extends Component {
         ...
          public void update(Graphics g) {
              if (isShowing()) {
                  if (! (peer instanceof java.awt.peer.LightweightPeer)) {
                      g.setColor(getBackground());
                      g.fillRect(0, 0, width, height);
                      g.setColor(getForeground());
                  }
                  super.update(g);
              }
          }
        ...
      }

      public abstract class Component ... {
         ...

          public void update(Graphics g) {
              if (! (peer instanceof java.awt.peer.LightweightPeer)) {
                  g.setColor(getBackground());
                  g.fillRect(0, 0, width, height);
                  g.setColor(getForeground());
              }
              paint(g);
          }
          ...
      }

      So, the default case is to fill in the background twice.
      I guess that this is not a big problem because folks usually
      completely overide update in subclasses of Container. Still,
      it's probably something to look at.

      -glenn

      -----End Original Message-----


      The following is a snipet from JDK 1.2b3 code:


      public class Container extends Component {
          . . .
          public void update(Graphics g) {
              if (isShowing()) {
                  if (! (peer instanceof java.awt.peer.LightweightPeer)) {
                      g.clearRect(0, 0, width, height);
                  }
                  super.update(g); // By default, Component.update() calls paint()
              }
          }
          . . .
      }


      public abstract class Component implements ImageObserver, MenuContainer,
          Serializable
      {
          . . .
          public void update(Graphics g) {
        if (! (peer instanceof java.awt.peer.LightweightPeer)) {
            g.clearRect(0, 0, width, height);
        }
        paint(g);
          }
          . . .
      }

      It seems you do the same double-clear-background thing here. But this seems slightly worse since
      the foreground and background colors are never set for lightweight components (as the comment on
      Component.update(Graphics g ) claims).
      (Review ID: 30058)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kdmsunw Kdm Kdm (Inactive)
                Reporter:
                bklocksunw Brian Klock (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: