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