RFR: 4337898: Serializing DefaultTableCellRenderer changes colors [v4]

Prasanta Sadhukhan psadhukhan at openjdk.org
Thu Dec 11 04:27:23 UTC 2025


On Wed, 10 Dec 2025 21:08:47 GMT, Phil Race <prr at openjdk.org> wrote:

> How/why does null restore the JTable-specified colors ? I don't see anything about null in the spec. And what have people been doing the last 25 years if serializing a JTable "broke" its rendering ?

Specifying null would cause `unselectedForeground` and `unselectedBackground` to be null
https://github.com/openjdk/jdk/blob/74dca863c2e61c13884c3454b8da7be125235970/src/java.desktop/share/classes/javax/swing/table/DefaultTableCellRenderer.java#L146-L148

 so it will fallback to table assigned foreground and background color 

https://github.com/openjdk/jdk/blob/74dca863c2e61c13884c3454b8da7be125235970/src/java.desktop/share/classes/javax/swing/table/DefaultTableCellRenderer.java#L215-L217
https://github.com/openjdk/jdk/blob/74dca863c2e61c13884c3454b8da7be125235970/src/java.desktop/share/classes/javax/swing/table/DefaultTableCellRenderer.java#L224-L226

Also, as is mentioned in the review https://github.com/openjdk/jdk/pull/28549#discussion_r2570711017 discerning gray with white can be difficult and not hugely different so maybe people have lived with it

-------------

PR Comment: https://git.openjdk.org/jdk/pull/28549#issuecomment-3640038716


More information about the client-libs-dev mailing list