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

Should discourage updating the GUI in the paint method

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P5 P5
    • None
    • 5.0
    • client-libs
    • generic
    • generic

      This article on painting
      http://java.sun.com/products/jfc/tsc/articles/painting/index.html
      should mention that it is a poor idea to change the GUI hierarchy in the
      paint() or update() method of a component. Perhaps we could put it in the
      AWT Painting Guidelines section? Below is some sample text.

      Changing the state of the GUI (e.g. adding an item to a List, or calling the
      setBackground() method of a Component) in the paint() or update() method of a
      Component is discouraged. These operations typically result in a new paint
      event being posted, so doing them in the paint() or update() method may
      cause a loop in which the paint method is called repeatedly.

      This may seem like an obvious error, but we have found several examples where
      programmers do this. Perhaps it is worth mentioning in the tutorial or some
      other docs.

            Unassigned Unassigned
            ehawkessunw Eric Hawkes (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: