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

paintAll incorrectly generates paint events instead of invoking paint directly

XMLWordPrintable

    • 1.1fcs
    • generic, x86
    • solaris_10, windows_nt
    • Not verified

      /*
      ** Stephen Blackheath 14 Dec 96
      ** This version of repaint doesn't work on 1.1 beta!
      ** The workaround is either to change 'paintAll(g)' to paint(g),
      ** or to remove the 'g.dispose()'.
      */
          public void repaint() {
              Graphics g = getGraphics();
              if ( g == null ) return;
              paintAll(g);
              g.dispose();
          }

      The problem is that Component.paintAll does this:
       public void paintAll(Graphics g) {
              ComponentPeer peer = this.peer;
              if (visible && (peer != null)) {
                  validate();
                  peer.paint(g);
              }
          }

      peer.paint(..) is routed to sun.awt.motif.MComponentPeer.paint, which
      does this:

          public void paint(Graphics g) {
              g.setColor(target.getForeground());
              g.setFont(target.getFont());
              postEvent(new PaintEvent(target, PaintEvent.PAINT, g));
              //target.paint(g);
          }

      In the beta version, 'target.paint(g)' was changed to 'postEvent(new PaintEvent
      ....'. The problem is that this queues a request to paint rather than
      painting immediately. By the time the paint is called, the Graphics
      object has already been dispose()'d by the caller (the Visible Human Project
      code).

      This needs to be done in another way!

            amfowler Anne Fowler (Inactive)
            amfowler Anne Fowler (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: