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

Semantics of getBounds((Rectangle)null), etc. undefined

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.2.0
    • 1.2.0
    • client-libs
    • swing1.0fcs
    • unknown
    • solaris_2.5.1

      From: Hans Muller <hmuller@Eng>
      To: ###@###.###
      Cc: ###@###.###
      Subject: JComponent's getSize, getBounds, etc.
      Date: Mon, 2 Feb 1998 08:04:00 -0800


      Good point, we'll try and get that in for Swing1.0.

      - Hans


      Rich Kadel writes:
       > In your new versions of getSize, etc. that take an object as a parameter
       > (so it doesn't have to allocate one), I recommend that you check for
       > null, then allocate one and return it only if null. This would be much
       > simpler and safer to use. For instance:
       >
       > public class SomeClass extends JComponent {
       > private Dimension size;
       >
       > public void doSomething() {
       > size = getSize(size);
       > // size is definitely valid now, and the newly allocated pointer
       > can now be reused
       > }
       > }
       >
       > Of course, this only works if getSize is implemented as:
       >
       > public Dimension getSize(Dimension rv) {
       > if (rv == null) rv = new Dimension();
       > rv.setSize(_bounds.width, _bounds.height);
       > return rv;
       > }
       >
       > This adds one line of code and doesn't break the existing
       > implementation.
       >
       > Thanks,
       > Rich
       > --
       >
       > |-------------------------------------------------------------------
       > | Rich Kadel
       > | DTAI, Incorporated - http://www.dtai.com
       > | mailto:###@###.###
       > | snailto: 3900 Harney Street, San Diego, CA 92110
       > | (619) 542-1700 - (FAX) 542-8675
       > |-------------------------------------------------------------------
       > | Java, C++, HTML, CGI, Windows, Unix, DBMS, 3D, ...
       > |-------------------------------------------------------------------
       >
       >
       >

            sswingtrsunw Swingtraq Swingtraq (Inactive)
            sswingtrsunw Swingtraq Swingtraq (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: