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

Insets recycling leads to layout problems!!

XMLWordPrintable

    • beta
    • generic
    • generic



      Name: dbT83986 Date: 12/27/98


      The description of the method Insets getInsets(Insets)
      in JComponent says that the buffer returned does not have
      to be the buffer given to the method as argument.
      But in the BasicLabelUI.paint(Graphics, JComponent) method,
      you assign the resulting buffer to a static member, to which
      others have access.

      This leads to the following problems:
      Every doLayout uses other insets, because the values in it get
      manipulated from different sources. The GUI-Compoents like
      JButton, JLabel returned high preferred sizes and the text in
      them got painted on very strange positions.

      Therefore you shouldn't assign the returned value to a static member.
      You don't have to change the strategy to avoid allocations of
      the Insets Object, but you have to use a temporary local
      reference in the paint method. I don't know if this problem resides
      even in other implementations, I hope not!

      Thanks
         P@trick
      (Review ID: 41830)
      ======================================================================

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: