jdk/src/share/classes/javax/swing/DefaultCellEditor.java
changeset 2658 43e06bc950ec
parent 2 90ce3da70b43
child 5506 202f599c92aa
--- a/jdk/src/share/classes/javax/swing/DefaultCellEditor.java	Fri Apr 17 16:28:02 2009 +0400
+++ b/jdk/src/share/classes/javax/swing/DefaultCellEditor.java	Sat Apr 25 21:17:50 2009 +0400
@@ -266,6 +266,26 @@
                                                  boolean isSelected,
                                                  int row, int column) {
         delegate.setValue(value);
+        if (editorComponent instanceof JCheckBox) {
+            //in order to avoid a "flashing" effect when clicking a checkbox
+            //in a table, it is important for the editor to have as a border
+            //the same border that the renderer has, and have as the background
+            //the same color as the renderer has. This is primarily only
+            //needed for JCheckBox since this editor doesn't fill all the
+            //visual space of the table cell, unlike a text field.
+            TableCellRenderer renderer = table.getCellRenderer(row, column);
+            Component c = renderer.getTableCellRendererComponent(table, value,
+                    isSelected, true, row, column);
+            if (c != null) {
+                editorComponent.setOpaque(true);
+                editorComponent.setBackground(c.getBackground());
+                if (c instanceof JComponent) {
+                    editorComponent.setBorder(((JComponent)c).getBorder());
+                }
+            } else {
+                editorComponent.setOpaque(false);
+            }
+        }
         return editorComponent;
     }