author | lana |
Thu, 26 Dec 2013 12:04:16 -0800 | |
changeset 23010 | 6dadb192ad81 |
parent 20428 | 929cd48fca8a |
child 25172 | b345c47c02b3 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23010
6dadb192ad81
8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents:
20428
diff
changeset
|
2 |
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package javax.swing.table; |
|
27 |
||
28 |
import java.awt.Component; |
|
29 |
import javax.swing.*; |
|
30 |
||
31 |
/** |
|
32 |
* This interface defines the method required by any object that |
|
33 |
* would like to be a renderer for cells in a <code>JTable</code>. |
|
34 |
* |
|
35 |
* @author Alan Chung |
|
36 |
*/ |
|
37 |
||
38 |
public interface TableCellRenderer { |
|
39 |
||
40 |
/** |
|
41 |
* Returns the component used for drawing the cell. This method is |
|
42 |
* used to configure the renderer appropriately before drawing. |
|
43 |
* <p> |
|
44 |
* The <code>TableCellRenderer</code> is also responsible for rendering the |
|
45 |
* the cell representing the table's current DnD drop location if |
|
46 |
* it has one. If this renderer cares about rendering |
|
47 |
* the DnD drop location, it should query the table directly to |
|
48 |
* see if the given row and column represent the drop location: |
|
49 |
* <pre> |
|
50 |
* JTable.DropLocation dropLocation = table.getDropLocation(); |
|
51 |
* if (dropLocation != null |
|
20428
929cd48fca8a
8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents:
5506
diff
changeset
|
52 |
* && !dropLocation.isInsertRow() |
929cd48fca8a
8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents:
5506
diff
changeset
|
53 |
* && !dropLocation.isInsertColumn() |
929cd48fca8a
8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents:
5506
diff
changeset
|
54 |
* && dropLocation.getRow() == row |
929cd48fca8a
8025249: [javadoc] fix some javadoc errors in javax/swing/
yan
parents:
5506
diff
changeset
|
55 |
* && dropLocation.getColumn() == column) { |
2 | 56 |
* |
57 |
* // this cell represents the current drop location |
|
58 |
* // so render it specially, perhaps with a different color |
|
59 |
* } |
|
60 |
* </pre> |
|
61 |
* <p> |
|
62 |
* During a printing operation, this method will be called with |
|
63 |
* <code>isSelected</code> and <code>hasFocus</code> values of |
|
64 |
* <code>false</code> to prevent selection and focus from appearing |
|
65 |
* in the printed output. To do other customization based on whether |
|
66 |
* or not the table is being printed, check the return value from |
|
67 |
* {@link javax.swing.JComponent#isPaintingForPrint()}. |
|
68 |
* |
|
69 |
* @param table the <code>JTable</code> that is asking the |
|
70 |
* renderer to draw; can be <code>null</code> |
|
71 |
* @param value the value of the cell to be rendered. It is |
|
72 |
* up to the specific renderer to interpret |
|
73 |
* and draw the value. For example, if |
|
74 |
* <code>value</code> |
|
75 |
* is the string "true", it could be rendered as a |
|
76 |
* string or it could be rendered as a check |
|
77 |
* box that is checked. <code>null</code> is a |
|
78 |
* valid value |
|
79 |
* @param isSelected true if the cell is to be rendered with the |
|
80 |
* selection highlighted; otherwise false |
|
81 |
* @param hasFocus if true, render cell appropriately. For |
|
82 |
* example, put a special border on the cell, if |
|
83 |
* the cell can be edited, render in the color used |
|
84 |
* to indicate editing |
|
85 |
* @param row the row index of the cell being drawn. When |
|
86 |
* drawing the header, the value of |
|
87 |
* <code>row</code> is -1 |
|
88 |
* @param column the column index of the cell being drawn |
|
89 |
* @see javax.swing.JComponent#isPaintingForPrint() |
|
90 |
*/ |
|
91 |
Component getTableCellRendererComponent(JTable table, Object value, |
|
92 |
boolean isSelected, boolean hasFocus, |
|
93 |
int row, int column); |
|
94 |
} |