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

JTable should not call cellRenderer for evey mouse move

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.0
    • client-libs



      Name: yyT116575 Date: 02/08/2001


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)


      JTable calls cellrender to get ToolTip text, but it does so for every mouse
      move. Since tooltip should be shown only when the mouse pointer is idle over a
      cell, mouse move event should not be sent to the renderer.

      I believe this to be a bug or at the very least a design flaw.

      This is particularly problematic when the renderer sets the color based on a
      database query. Moving the mouse pointer over the cells floods the net with
      database queries.

      Look at the console when you move the mouse pointer over the cells...

      test code


      import javax.swing.*;
      import javax.swing.table.*;
      import java.awt.*;

      public class RendererTest extends DefaultTableCellRenderer {
        public Component getTableCellRendererComponent( JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column) {
          Component comp = super.getTableCellRendererComponent(table, value, isSelected,
              hasFocus, row, column);
          System.out.println( "rendering row: " + row + "; column: " + column);
          return comp;
        }

        public static void main(String args[]) {
          Object rows[][] = {{"A", "1"}, {"B", "2"}};
          Object headers[] = {"Letters", "Numbers"};
          JFrame frame = new JFrame("Renderer Test");
          JTable table = new JTable(rows, headers);
          TableCellRenderer renderer = new RendererTest();
          table.setDefaultRenderer(Object.class, renderer);
          JScrollPane scrollPane = new JScrollPane(table);
          frame.getContentPane().add(scrollPane, BorderLayout.CENTER);
          frame.setSize(300, 150);
          frame.setVisible(true);
        }
      }
      (Review ID: 116611)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            yyoungsunw Yung-ching Young (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: