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

javax.swing.text.Utilities.getTabbedTextOffset returns incorrect value at end of text when fractional metrics are enabled

    XMLWordPrintable

Details

    Description

      FULL PRODUCT VERSION :


      A DESCRIPTION OF THE PROBLEM :
      I am filing this bug report at the request of Phil Race.

      There is a problem in the method javax.swing.text.Utilities.getTabbedTextOffset. This problem may or may not be visible at this time as it depends on fractional metrics being enabled. I am not aware of any legitimate way to enable fractional metrics currently.

      The implementation of this method has two steps. It first uses a loop to identify a candidate position. It then corrects the position, if needed. The need for the correction is environment dependent. For example, the correction is needed if fractional metrics are enabled.

      The correction is implemented inside the for loop, in a conditional that exits the loop. The problem is that when the candidate position is at the end of the text, this conditional is never executed; instead, the loop terminates normally. Therefore, if the correction was needed, the result is incorrect (the position exceeds the width of the text display).

      Solution: the corrrection code should be after the loop, not inside the loop.



      REPRODUCIBILITY :
      This bug can be reproduced always.

      CUSTOMER SUBMITTED WORKAROUND :
      It is possible to double check the result of this method and correct it using information obtained by the modelToView() method.

      Attachments

        Issue Links

          Activity

            People

              rmahajan Rajat Mahajan
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: