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

Insufficient repaint after JTable header multiline tooltip

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      The problem also appears using openjdk-17-ea+30_windows-x64_bin

      A DESCRIPTION OF THE PROBLEM :
      The table contains blank areas after a multiline tooltip for the table header is hidden. The last row overlapping the tooltip is affected.

      This is a follow-up to JDK-8214539 where the problem was reported for single line tooltips.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Move the mouse to the table header.
      2. Wait until the tooltip is displayed.
      3. Wait until the tooltip is hidden.
      4. Observe blank areas in the last row the tooltip overlapped with.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Repaint of entire area covered by tooltip.
      ACTUAL -
      Unexpected blank areas in the last row the tooltip overlapped with.

      ---------- BEGIN SOURCE ----------
      import javax.swing.JDialog;
      import javax.swing.JPanel;
      import javax.swing.JTable;
      import javax.swing.SwingUtilities;
      import javax.swing.WindowConstants;
      import javax.swing.table.DefaultTableModel;
      import java.awt.BorderLayout;
      import java.awt.Window;

      public class TableHeaderToolTipBug {
         private TableHeaderToolTipBug() {
         }

         public static void main(String[] args) {
            SwingUtilities.invokeLater(TableHeaderToolTipBug::run);
         }

         private static void run() {
            Object[][] data = new Object[5][];
            for (int i = 0; i < data.length; i++) {
               data[i] = new Object[]{11111111, 22222222, 33333333, 44444444, 55555555};
            }
            JTable table = new JTable(new DefaultTableModel(data, new String[]{"1", "2", "3", "4", "5"}));
            table.getTableHeader().setToolTipText("<html>This is a table header tooltip<br>with more than<br>one line");

            JPanel panel = new JPanel(new BorderLayout());
            panel.add(table.getTableHeader(), BorderLayout.NORTH);
            panel.add(table);

            JPanel anotherPanel = new JPanel(new BorderLayout());
            anotherPanel.add(panel);

            JDialog dialog = new JDialog((Window) null, "Table header tooltip");
            dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            dialog.add(anotherPanel);
            dialog.setSize(600, 400);
            dialog.setLocationRelativeTo(null);
            dialog.setVisible(true);
         }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Otherwise trigger a repaint. (For example by resizing the window.)

      FREQUENCY : always


            psadhukhan Prasanta Sadhukhan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: