Merge branch 'subtree'
[fanfix.git] / ui / compat / ListCellRenderer6.java
1 package be.nikiroo.utils.ui.compat;
2
3 import java.awt.Component;
4
5 import javax.swing.JList;
6 import javax.swing.ListCellRenderer;
7 import javax.swing.ListModel;
8 import javax.swing.ListSelectionModel;
9
10 /**
11 * Compatibility layer so I can at least get rid of the warnings of using
12 * {@link JList} without a parameter (and still staying Java 1.6 compatible).
13 * <p>
14 * This class is merely a {@link ListCellRenderer} that you can parametrise also
15 * in Java 1.6.
16 *
17 * @author niki
18 *
19 * @param <E>
20 * the type to use
21 */
22 @SuppressWarnings({ "unchecked", "rawtypes" }) // not compatible Java 1.6
23 public abstract class ListCellRenderer6<E> implements ListCellRenderer {
24 @Override
25 @Deprecated
26 /**
27 * @deprecated please use@deprecated please use
28 * {@link ListCellRenderer6#getListCellRendererComponent(JList6, Object, int, boolean, boolean)}
29 * instead
30 * {@link ListCellRenderer6#getListCellRendererComponent(JList6, Object, int, boolean, boolean)}
31 * instead
32 */
33 public Component getListCellRendererComponent(JList list, Object value,
34 int index, boolean isSelected, boolean cellHasFocus) {
35 return getListCellRendererComponent((JList6<E>) list, (E) value, index,
36 isSelected, cellHasFocus);
37 }
38
39 /**
40 * Return a component that has been configured to display the specified
41 * value. That component's <code>paint</code> method is then called to
42 * "render" the cell. If it is necessary to compute the dimensions of a list
43 * because the list cells do not have a fixed size, this method is called to
44 * generate a component on which <code>getPreferredSize</code> can be
45 * invoked.
46 *
47 * @param list
48 * The JList we're painting.
49 * @param value
50 * The value returned by list.getModel().getElementAt(index).
51 * @param index
52 * The cells index.
53 * @param isSelected
54 * True if the specified cell was selected.
55 * @param cellHasFocus
56 * True if the specified cell has the focus.
57 * @return A component whose paint() method will render the specified value.
58 *
59 * @see JList
60 * @see ListSelectionModel
61 * @see ListModel
62 */
63 public abstract Component getListCellRendererComponent(JList6<E> list,
64 E value, int index, boolean isSelected, boolean cellHasFocus);
65 }