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

JTable displays tooltip containing only the word "null"

    XMLWordPrintable

    Details

      Description

      FULL PRODUCT VERSION :
      java version "1.4.2_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_01-b06)
      Java HotSpot(TM) Client VM (build 1.4.2_01-b06, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows 2000 Professional

      A DESCRIPTION OF THE PROBLEM :
      In JTable.initializeLocalVars, JTable registers itself with ToolTipManager whether it has tooltip text or not, on the grounds that any of its renderers may have a tooltip text; if any renderer doesn't have a tooltip text, then JTable uses its own, which may be null. So you end up with little popup tooltip windows any time the mouse rests on the JTable, with the very informative text "null".

      Currently, ToolTipManager assumes that if a component is registered with it, then it has non-null tip text (an assumption that is not provable). In the constructor for ToolTipManager, where it initializes postTipAction, the code should test the toolTipText value returned by insideComponent.getToolTipText(), and if it is null, should not call ShowTipWindow nor create the following FocusChangeListener.

      This is a very easy fix that cannot possibly affect anything else adversely.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Subclass a cell renderer to create one with tooltip text. Make it the renderer for a JTable column, but do not otherwise set tooltip text for the JTable.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Where there is no tooltip, no tooltip window should appear.
      ACTUAL -
      When running, if the mouse is over the column with the special cell renderer, that renderer's tooltip appears. Anywhere else in the JTable (including the header), a tooltip window pops up with the word "null" proudly displayed.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No error messages, no crash.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      No longer available. Just look in the source code in the places I mention above: the bug is obvious enough.

      In the constructor for ToolTipManager, where it initializes postTipAction, the code assumes the toolTipText value returned by insideComponent.getToolTipText() is null, which is not a valid assumption. It should test the value before showing the tip window and creating a FocusChangeListener
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Make sure all JTables have a tip text, no matter how trivial, or explicitly call JTable.setTipText(null) after initialization which disables the tooltips of all renderer components as well.

        Attachments

          Activity

            People

            Assignee:
            alexp Alexander Potochkin (Inactive)
            Reporter:
            shickeysunw Shannon Hickey (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: