Why do cell renderers often extend JLabel?
问题 I noticed this is common. For example DefaultListCellRenderer, DefaultTableCellRenderer, and DefaultTreeCellRenderer all use it. Also a lot of the custom cell renderers I see online use this as well. I want to use a custom TableCellRenderer in my code, but I'm confused about whether I really need to subclass JLabel. What's the benefit of subclassing JLabel? 回答1: The API for the DefaultTableCellRenderer states: The table class defines a single cell renderer and uses it as a as a rubber-stamp