-  
        
       
 public interface TableCellRenderer此接口定义了任何想要成为JTable单元格渲染器的对象所需的方法。
-  
        
       -  
             方法详细信息-  getTableCellRendererComponentComponent getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) 返回用于绘制单元格的组件。 此方法用于在绘制之前适当地配置渲染器。TableCellRenderer还负责呈现表示表的当前DnD丢弃位置的单元(如果有)。 如果此渲染器关注渲染DnD放置位置,它应该直接查询表以查看给定的行和列是否表示放置位置:JTable.DropLocation dropLocation = table.getDropLocation(); if (dropLocation != null && !dropLocation.isInsertRow() && !dropLocation.isInsertColumn() && dropLocation.getRow() == row && dropLocation.getColumn() == column) { // this cell represents the current drop location // so render it specially, perhaps with a different color }在打印操作期间,将使用 isSelected和hasFocus值false调用此方法,以防止选择和焦点出现在打印输出中。 要根据是否正在打印表格进行其他自定义,请检查JComponent.isPaintingForPrint()的返回值。- 参数
-  
              table- 要求渲染器绘制的JTable; 可以是null
-  
              value- 要呈现的单元格的值。 由特定渲染器来解释和绘制值。 例如,如果value是字符串“true”,则可以将其呈现为字符串,也可以将其呈现为已选中的复选框。null是有效值
-  
              isSelected- 如果要在突出显示选区的情况下渲染单元格,则为true;否则为false。 否则是假的
-  
              hasFocus- 如果为true,则适当地渲染单元格。 例如,在单元格上放置一个特殊边框,如果可以编辑单元格,则使用用于指示编辑的颜色进行渲染
-  
              row- 正在绘制的单元格的行索引。 绘制标题时,row值为-1
-  
              column- 正在绘制的单元格的列索引
- 结果
- 用于绘制单元格的组件。
- 另请参见:
-  
              JComponent.isPaintingForPrint()
 
 
-  
 
-