classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: Render null as the empty cell in JTable


From: Meskauskas Audrius
Subject: [cp-patches] FYI: Render null as the empty cell in JTable
Date: Sun, 15 Jan 2006 18:40:24 +0100
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

If the JTable model returns null, our recent implementation does not set the value at all. The visible content of such cell replicates the value of the adjacent cell. Sun's implementation renders the null value as the empty cell. With one user application I have observed the strange content replication for the cells that should be displayed as empty. This path sets the empty string value for the renderer is such case, making our
behavior identical with Sun's.

2006-01-15  Audrius Meskauskas  <address@hidden>

* javax/swing/table/DefaultTableCellRenderer.java (getTableCellRendererComponent):
Render null as the empty cell.
Index: javax/swing/table/DefaultTableCellRenderer.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/swing/table/DefaultTableCellRenderer.java,v
retrieving revision 1.23
diff -u -r1.23 DefaultTableCellRenderer.java
--- javax/swing/table/DefaultTableCellRenderer.java     24 Nov 2005 20:26:35 
-0000      1.23
+++ javax/swing/table/DefaultTableCellRenderer.java     15 Jan 2006 17:24:08 
-0000
@@ -127,7 +127,8 @@
    * Get the string value of the object and pass it to setText().
    *
    * @param table the JTable
-   * @param value the value of the object
+   * @param value the value of the object. For the text content,
+   *        null is rendered as an empty cell.
    * @param isSelected is the cell selected?
    * @param hasFocus has the cell the focus?
    * @param row the row to render
@@ -146,6 +147,9 @@
           return new JTextField(((JTextField)value).getText());
         super.setText(value.toString());
       }
+    else
+      // null is rendered as an empty cell.
+      super.setText("");
 
     setOpaque(true);
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]