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

Scrollable.getScrollableUnitIncrement() behavior is under-specified

XMLWordPrintable

      The JavaDoc for the getScrollableUnitIncrement() method of the javax.swing.Scrollable interface describes the correct behavior only if the scroll direction is < 0.

      The getScrollableUnitIncrement() docs are as follows:
      "Components that display logical rows or columns should compute the scroll increment that will completely expose one new row or column, depending on the value of orientation. Ideally, components should handle a partially exposed row or column by returning the distance required to completely expose the item."

      GUI components that display tabular data (spreadsheets, the "Details" view in the Windows Explorer, etc) align their data with the top edge of the enclosing scroll context. This feels natural because we are used to reading data from top to bottom.

      When we scroll such a component one unit upwards (direction < 0), we expect an additional row to appear from the top, aligned with the top of the scrollpane. Alternatively, if the row at the top of the table is only partially visible, when we scroll up we expect the top row to become fully visible, becoming aligned with the top of the scrollpane. The getScrollableUnitIncrement() docs are correct for these situations.

      However, when scrolling downwards (direction > 0), new rows appear from the bottom of the table, but the table should still remain aligned with the TOP of the scrollpane. In this situation, we don't necessarily want to scroll by the amount that will completely expose a new row from the bottom, because this will more than likely cause the top of the table to become misaligned. Instead, we want to scroll by the amount that will hide the row at the top of the table, such that the following row becomes aligned at the top.

      The getScrollableUnitIncrement() JavaDoc should be updated to better reflect the desired behavior.

            shickeysunw Shannon Hickey (Inactive)
            bchristi Brent Christian
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: