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

invalid initial value of FixedHeightLayoutCache.getRowHeight()

XMLWordPrintable

    • beta
    • sparc
    • solaris_2.5



      Name: sdC67446 Date: 02/10/99


      The initial value of getRowHeight() is 0. The call of setRowHeight(0) throws
      IllegalArgumentException - "FixedHeightLayoutCache only supports row
      heights greater than 0". Also the call of getPathClosestTo(int x, int
      y) causes ArithmeticException (dividing by zero).

      The doc says:
      --------------------------------------------------
      public void setRowHeight(int rowHeight)

             Sets the height of each cell. If rowHeight is less than or
             equal to 0 this will throw an IllegalArgumentException.
             Parameters:
                    rowHeight - the height of each cell, in pixels
             Overrides:
                    setRowHeight in class AbstractLayoutCache


      // from AbstractLayoutCache class //
      public int getRowHeight()

             Returns the height of each row. If the returned value is less
             than or equal to 0 the height for each row is determined by the
             renderer.
             Parameters:
                    the - height of each cell, in pixels. Zero or negative
             if the height of each row is determined by the tree cell
             renderer


      The test demonstrating the bug:
      -----------------Test.java------------------------
      import javax.swing.tree.*;

      public class Test {
          public static void main(String[] args) {
      FixedHeightLayoutCache fhlc = new FixedHeightLayoutCache();

      try {
      System.out.println("fhlc.getRowHeight() = "+ fhlc.getRowHeight());
      fhlc.setRowHeight(10);
      System.out.println("fhlc.getRowHeight() = "+ fhlc.getRowHeight());
      fhlc.setRowHeight(0);
      System.out.println("fhlc.getRowHeight() = "+ fhlc.getRowHeight());
      } catch (Exception e) {
      System.out.println(e);
      }
          }
      }
      ---------Output from the test---------------------
      fhlc.getRowHeight() = 0
      fhlc.getRowHeight() = 10
      java.lang.IllegalArgumentException: FixedHeightLayoutCache only
      supports row heights greater than 0
      --------------------------------------------------
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            dsvsunw Dsv Dsv (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: