< prev index next >

src/java.desktop/share/classes/javax/swing/ListCellRenderer.java

Print this page




  74  *         setForeground(foreground);
  75  *
  76  *         return this;
  77  *     }
  78  * }
  79  * }
  80  * </pre>
  81  *
  82  * @param <E> the type of values this renderer can be used for
  83  *
  84  * @see JList
  85  * @see DefaultListCellRenderer
  86  *
  87  * @author Hans Muller
  88  * @since 1.2
  89  */
  90 public interface ListCellRenderer<E>
  91 {
  92     /**
  93      * Return a component that has been configured to display the specified
  94      * value. That component's <code>paint</code> method is then called to
  95      * "render" the cell.  If it is necessary to compute the dimensions
  96      * of a list because the list cells do not have a fixed size, this method
  97      * is called to generate a component on which <code>getPreferredSize</code>
  98      * can be invoked.
  99      *
 100      * @param list The JList we're painting.
 101      * @param value The value returned by list.getModel().getElementAt(index).
 102      * @param index The cells index.
 103      * @param isSelected True if the specified cell was selected.
 104      * @param cellHasFocus True if the specified cell has the focus.
 105      * @return A component whose paint() method will render the specified value.
 106      *
 107      * @see JList
 108      * @see ListSelectionModel
 109      * @see ListModel
 110      */
 111     Component getListCellRendererComponent(
 112         JList<? extends E> list,
 113         E value,
 114         int index,
 115         boolean isSelected,
 116         boolean cellHasFocus);
 117 }


  74  *         setForeground(foreground);
  75  *
  76  *         return this;
  77  *     }
  78  * }
  79  * }
  80  * </pre>
  81  *
  82  * @param <E> the type of values this renderer can be used for
  83  *
  84  * @see JList
  85  * @see DefaultListCellRenderer
  86  *
  87  * @author Hans Muller
  88  * @since 1.2
  89  */
  90 public interface ListCellRenderer<E>
  91 {
  92     /**
  93      * Return a component that has been configured to display the specified
  94      * value. That component's {@code paint} method is then called to
  95      * "render" the cell.  If it is necessary to compute the dimensions
  96      * of a list because the list cells do not have a fixed size, this method
  97      * is called to generate a component on which {@code getPreferredSize}
  98      * can be invoked.
  99      *
 100      * @param list The JList we're painting.
 101      * @param value The value returned by list.getModel().getElementAt(index).
 102      * @param index The cells index.
 103      * @param isSelected True if the specified cell was selected.
 104      * @param cellHasFocus True if the specified cell has the focus.
 105      * @return A component whose paint() method will render the specified value.
 106      *
 107      * @see JList
 108      * @see ListSelectionModel
 109      * @see ListModel
 110      */
 111     Component getListCellRendererComponent(
 112         JList<? extends E> list,
 113         E value,
 114         int index,
 115         boolean isSelected,
 116         boolean cellHasFocus);
 117 }
< prev index next >