home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1998 November
/
Chip_1998-11_cd.bin
/
tema
/
Cafe
/
jfc.bin
/
ListCellRenderer.java
< prev
next >
Wrap
Text File
|
1998-02-26
|
3KB
|
85 lines
/*
* @(#)ListCellRenderer.java 1.8 98/01/30
*
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
*
* This software is the confidential and proprietary information of Sun
* Microsystems, Inc. ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Sun.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
* SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
* SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
* THIS SOFTWARE OR ITS DERIVATIVES.
*
*/
package com.sun.java.swing;
import java.awt.Component;
/**
* Components that are to be used as "rubber stamps" to paint the
* cells in a JList, must implement this interface. For example
* to us a JLabel as a ListCellRenderer one would write something
* like this:
* <pre>
* class MyCellRenderer extends JLabel implements ListCellRenderer {
* public MyCellRenderer() {
* setOpaque(true);
* }
* public Component getListCellRendererComponent(
* JList list,
* Object value,
* int index,
* boolean isSelected,
* boolean cellHasFocus)
* {
* setText(value.toString());
* setBackground(isSelected ? Color.red : Color.white);
* setForeground(isSelected ? Color.white : Color.black);
* return this;
* }
* }
* </pre>
*
* @see JList
* @see basic.BasicListCellRenderer
*
* @version 1.8 01/30/98
* @author Hans Muller
*/
public interface ListCellRenderer
{
/**
* Return a component that's been configured to display the specified
* value. The components paint method will be called subsequently to
* "render" the cell. If it's neccessary to compute the dimensions
* of the list, e.g. if the list cells aren't fixed size, this method
* will be called to generate a component to apply getPreferredSize() to.
*
* @param list The JList we're painting.
* @param value The value returned by list.getModel().getElementAt(index).
* @param index The cells index.
* @param isSelected True if the specified cell was selected.
* @param cellHasFocus True if the specified cell has the focus.
* @return A component whose paint() method will render the specified value.
*
* @see JList
* @see ListSelectionModel
* @see ListModel
*/
Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus);
}