2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License as published by
4
* the Free Software Foundation; either version 2 of the License, or
5
* (at your option) any later version.
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software
14
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
* InfoPanelCellRenderer.java
19
* Copyright (C) 2005 University of Waikato, Hamilton, New Zealand
25
import java.awt.Component;
27
import javax.swing.JLabel;
28
import javax.swing.JList;
29
import javax.swing.ListCellRenderer;
32
* A specialized renderer that takes care of JLabels in a JList.
34
* @author FracPete (fracpete at waikato dot ac dot nz)
35
* @version $Revision: 1.2 $
38
public class InfoPanelCellRenderer
40
implements ListCellRenderer {
42
/** for serialization */
43
private static final long serialVersionUID = -533380118807178531L;
48
public InfoPanelCellRenderer() {
54
* Return a component that has been configured to display the specified value.
55
* @param list The JList we're painting.
56
* @param value The value returned by list.getModel().getElementAt(index).
57
* @param index The cells index.
58
* @param isSelected True if the specified cell was selected.
59
* @param cellHasFocus True if the specified cell has the focus.
61
public Component getListCellRendererComponent(
62
JList list, Object value,
63
int index, boolean isSelected, boolean cellHasFocus) {
65
if (value instanceof JLabel) {
66
setIcon(((JLabel) value).getIcon());
67
setText(((JLabel) value).getText());
71
setText(value.toString());
75
setBackground(list.getSelectionBackground());
76
setForeground(list.getSelectionForeground());
79
setBackground(list.getBackground());
80
setForeground(list.getForeground());
82
setEnabled(list.isEnabled());
83
setFont(list.getFont());