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

javax.swing.SizeSequence.setSize(int, int) works wrong

XMLWordPrintable



      Name: sdC67446 Date: 09/20/99


      The method
          public void setSize(int index, int size)
      of class
          javax.swing.SizeSequence
      has perverse idea of right behaviour if 'index'<0:
      the method adds 'size' to first size cell.

      The doc says:
      --------------------------------------------------
      public void setSize(int index,
                          int size)

           Sets the size of the specified entry.
           Parameters:
               index - the index corresponding to the entry
               size - the size of the entry

      The demo test:
      --------------------------------------------------
      import javax.swing.SizeSequence;
      public class Test {
          public static void main(String argv[]) {
              int[] sizes = {1000, 2000, 3000};
              SizeSequence ss = new SizeSequence();
              ss.setSizes(sizes);

              System.out.println("before:");
              for (int i=0; i<sizes.length; i++) {
                  System.out.println(i+": "+ss.getSize(i));
              }

              ss.setSize(-1, 777);
              System.out.println("after:");
              for (int i=0; i<sizes.length; i++) {
                  System.out.println(i+": "+ss.getSize(i));
              }
          }
      }

      --------------------------------------------------
      before:
      0: 1000
      1: 2000
      2: 3000
      after:
      0: 1777
      1: 2000
      2: 3000

      --------------------------------------------------
      ======================================================================

            pmilnesunw Philip Milne (Inactive)
            dsvsunw Dsv Dsv (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: