| 
 | JavaTM 2 Platform Standard Ed. 6 | |||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
public interface TableCellRenderer
此接口定义了要成为 JTable 中单元格渲染器的任意对象所需的方法。
| 方法摘要 | |
|---|---|
|  Component | getTableCellRendererComponent(JTable table,
                              Object value,
                              boolean isSelected,
                              boolean hasFocus,
                              int row,
                              int column)返回用于绘制单元格的组件。 | 
| 方法详细信息 | 
|---|
Component 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;可以为 nullvalue - 要呈现的单元格的值。由具体的渲染器解释和绘制该值。例如,如果 value 是字符串 "true",则它可呈现为字符串,或者也可呈现为已选中的复选框。null 是有效值isSelected - 如果使用选中样式的高亮显示来呈现该单元格,则为 true;否则为 falsehasFocus - 如果为 true,则适当地呈现单元格。例如,在单元格上放入特殊的边框,如果可以编辑该单元格,则以彩色呈现它,用于指示正在进行编辑row - 要绘制的单元格的行索引。绘制头时,row 值是 -1column - 要绘制的单元格的列索引JComponent.isPaintingForPrint()| 
 | JavaTM 2 Platform Standard Ed. 6 | |||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only。