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

Component.paint() misleading about need to call super

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_2000

      Description

      FULL PRODUCT VERSION :
      java version "1.5.0_04"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
      "Subclasses of Component that override this method need not call super.paint(g)."

      This is incorrect, and the actual requirements require detective work throughout the inheritance tree, or blindly trying until things work. Since the whole situation is rather "confusing" (this is a euphemism), programmers need all the help they can get, and should not be confronted with inaccuracies or incomplete truths.

      An absolute minimal cure is to substitute "Direct subclasses" for "Subclasses".

      A good solution seems to require a whole lot more work than that. For example, Canvas says that "The default operation is simply to clear the canvas.", but that apparently already happens outside of paint(), so the default behaviour seems to be to do nothing, but is that true in general, etc. Another example is the initial setup and scope of the Graphics argument, which seems to affect child Component objects as well, according to Container (why?), but it's not immediately clear whether it also affects later siblings and ancestors' later siblings and their descendants, although that seems a likely corrollary, and the consequence seems to be that one should always work with a copy of the supplied Graphics, but how expensive is that, etc., etc.



      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      Test changes until things work and don't desire to fully understand?

        Attachments

          Activity

            People

            Assignee:
            son Oleg Sukhodolsky (Inactive)
            Reporter:
            dav Andrei Dmitriev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: