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

poor doc for javax.swing.SizeSequence.getPosition(int)

XMLWordPrintable

    • beta
    • sparc
    • solaris_2.6



      Name: sdC67446 Date: 09/20/99


      The doc for method
          public int javax.swing.SizeSequence.getPosition(int index)
      of class
          javax.swing.SizeSequence
      says nothing about expected method's behaviour if 'index' points to
      unexistent size cell ('index' >= getSizes.length).

      The doc says:
      ------------------------------------------------------------
      public int getPosition(int index)

           Returns the start position for the specified entry. For example,
           getPosition(0) returns 0, getPosition(1) is equal to getSize(0),
           getPosition(2) is equal to getSize(0) + getSize(1), and so on.
           Parameters:
               index - the index of the entry whose position is desired
           Returns:
               the starting position of the specified entry

      The demo test:
      ------------------------------------------------------------
      import javax.swing.SizeSequence;
      public class Test {
          public static void main(String argv[]) {
              int[] sizes = {10, 20, 30};
              SizeSequence ss = new SizeSequence();
              ss.setSizes(sizes);
              int sum = 0;
              for (int i=0; i<sizes.length; sum += sizes[i++]);
              
              for (int i=0; i<sizes.length; i++) {
                  System.out.println(i+": "+ss.getPosition(i));
              }
              System.out.println("---");
              for (int i=sizes.length; i<sizes.length+5; i++) {
                  System.out.println(i+": "+ss.getPosition(i));
              }
          }
      }

      Output:
      ------------------------------------------------------------
      0: 0
      1: 10
      2: 30
      ---
      3: 60
      4: 60
      5: 60
      6: 60
      7: 60

      ======================================================================

            sharonz Sharon Zakhour (Inactive)
            dsvsunw Dsv Dsv (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: