68 * } else {
69 * background = Color.WHITE;
70 * foreground = Color.BLACK;
71 * };
72 *
73 * setBackground(background);
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 */
89 public interface ListCellRenderer<E>
90 {
91 /**
92 * Return a component that has been configured to display the specified
93 * value. That component's <code>paint</code> method is then called to
94 * "render" the cell. If it is necessary to compute the dimensions
95 * of a list because the list cells do not have a fixed size, this method
96 * is called to generate a component on which <code>getPreferredSize</code>
97 * can be invoked.
98 *
99 * @param list The JList we're painting.
100 * @param value The value returned by list.getModel().getElementAt(index).
101 * @param index The cells index.
102 * @param isSelected True if the specified cell was selected.
103 * @param cellHasFocus True if the specified cell has the focus.
104 * @return A component whose paint() method will render the specified value.
105 *
106 * @see JList
107 * @see ListSelectionModel
|
68 * } else {
69 * background = Color.WHITE;
70 * foreground = Color.BLACK;
71 * };
72 *
73 * setBackground(background);
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
|