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

Wrong behavior/Javadoc of JTable.tableChanged(TableModelEvent e)

    XMLWordPrintable

Details

    Description

      Javadoc of JTable.tableChanged(TableModelEvent e) says:
           * The <code>TableModelEvent</code> should be constructed in the
           * coordinate system of the model; the appropriate mapping to the
           * view coordinate system is performed by this <code>JTable</code>
           * when it receives the event.

      But this is not true! The column is correctly converted:

          int modelColumn = e.getColumn();
          ...
          int column = convertColumnIndexToView(modelColumn);
          ...

      but the rows are not converted at all:
          int start = e.getFirstRow();
          int end = e.getLastRow();
          ...
          dirtyRegion = getCellRect(start, column, false);
          ...
      Reopening.
      It's true that in the middle of some long description there is some complicated text that tells us that you have to convert the row indexes to be in terms of the view.

      But the Javadoc of tableChanged(TableModelEvent e) is clear:
          "* The <code>TableModelEvent</code> should be constructed in the
           * coordinate system of the model; the appropriate mapping to the
           * view coordinate system is performed by this <code>JTable</code>
           * when it receives the event."
      This implies a false assumption that tableChanged() method needs to have the row from the *model* (coordinate system of the model).

      Since the behavior can not be changed because of compatibility, the Javadoc should be corrected to explicitly say that the column should be in the coordinate system of the model and the row in the coordinate system of the view.
      Do we want to help developers to use our APIs or not?

      Attachments

        Issue Links

          Activity

            People

              honkar Harshitha Onkar
              mentlich Martin Entlicher
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: