0N/A/*
2362N/A * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.swing.table;
0N/A
0N/Aimport java.awt.Component;
0N/Aimport javax.swing.*;
0N/A
0N/A/**
0N/A * This interface defines the method required by any object that
0N/A * would like to be a renderer for cells in a <code>JTable</code>.
0N/A *
0N/A * @author Alan Chung
0N/A */
0N/A
0N/Apublic interface TableCellRenderer {
0N/A
0N/A /**
0N/A * Returns the component used for drawing the cell. This method is
0N/A * used to configure the renderer appropriately before drawing.
0N/A * <p>
0N/A * The <code>TableCellRenderer</code> is also responsible for rendering the
0N/A * the cell representing the table's current DnD drop location if
0N/A * it has one. If this renderer cares about rendering
0N/A * the DnD drop location, it should query the table directly to
0N/A * see if the given row and column represent the drop location:
0N/A * <pre>
0N/A * JTable.DropLocation dropLocation = table.getDropLocation();
0N/A * if (dropLocation != null
0N/A * && !dropLocation.isInsertRow()
0N/A * && !dropLocation.isInsertColumn()
0N/A * && dropLocation.getRow() == row
0N/A * && dropLocation.getColumn() == column) {
0N/A *
0N/A * // this cell represents the current drop location
0N/A * // so render it specially, perhaps with a different color
0N/A * }
0N/A * </pre>
0N/A * <p>
0N/A * During a printing operation, this method will be called with
0N/A * <code>isSelected</code> and <code>hasFocus</code> values of
0N/A * <code>false</code> to prevent selection and focus from appearing
0N/A * in the printed output. To do other customization based on whether
0N/A * or not the table is being printed, check the return value from
0N/A * {@link javax.swing.JComponent#isPaintingForPrint()}.
0N/A *
0N/A * @param table the <code>JTable</code> that is asking the
0N/A * renderer to draw; can be <code>null</code>
0N/A * @param value the value of the cell to be rendered. It is
0N/A * up to the specific renderer to interpret
0N/A * and draw the value. For example, if
0N/A * <code>value</code>
0N/A * is the string "true", it could be rendered as a
0N/A * string or it could be rendered as a check
0N/A * box that is checked. <code>null</code> is a
0N/A * valid value
0N/A * @param isSelected true if the cell is to be rendered with the
0N/A * selection highlighted; otherwise false
0N/A * @param hasFocus if true, render cell appropriately. For
0N/A * example, put a special border on the cell, if
0N/A * the cell can be edited, render in the color used
0N/A * to indicate editing
0N/A * @param row the row index of the cell being drawn. When
0N/A * drawing the header, the value of
0N/A * <code>row</code> is -1
0N/A * @param column the column index of the cell being drawn
0N/A * @see javax.swing.JComponent#isPaintingForPrint()
0N/A */
0N/A Component getTableCellRendererComponent(JTable table, Object value,
0N/A boolean isSelected, boolean hasFocus,
0N/A int row, int column);
0N/A}