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

JTable setRowHeight(int, int) executes and repaints needlessly

    XMLWordPrintable

    Details

      Description

      A DESCRIPTION OF THE REQUEST :
      Method setRowHeight(int row, int rowHeight) in JTable does not check if parameter rowHeight is equal to the value returned by getRowHeight(int row) before executing and calling its resizeAndRepaint() method.

      JUSTIFICATION :
      When method setRowHeight(int, int) is called from a TableCellRenderer, this forces the table to call repaint() and infinite number of times and consuming large, unnecessary amounts of CPU.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Method setRowHeight(int row, int rowHeight) would not execute anything if getRowHeight(int row) is equal to parameter rowHeight.
      ACTUAL -
      Method setRowHeight(int row, int rowHeight) executes regardless of the value returned by getRowHeight(int row). This essentially prevents method setRowHeight(int row, int rowHeight) from being called in a TableCellRenderer without serious performance issues.

      CUSTOMER SUBMITTED WORKAROUND :
      Callers should ensure their desired row height does not equal the value returned by getRowHeight(int row) before calling setRowHeight(int row, int rowHeight).

      JTable can also be extended and method setRowHeight can be overridden as follows:

      @Override
          public void setRowHeight(int row, int rowHeight)
          {
              if(super.getRowHeight(row) != rowHeight)
              {
                  super.setRowHeight(row, rowHeight);
              }
          }

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: