01: package hero.client.manager;
02:
03: /*
04: *
05: * ManagerCellRenderer.java -
06: * Copyright (C) 2002 Ecoo Team
07: * valdes@loria.fr
08: *
09: *
10: * This program is free software; you can redistribute it and/or
11: * modify it under the terms of the GNU Lesser General Public License
12: * as published by the Free Software Foundation; either version 2
13: * of the License, or (at your option) any later version.
14: *
15: * This program is distributed in the hope that it will be useful,
16: * but WITHOUT ANY WARRANTY; without even the implied warranty of
17: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: * GNU Lesser General Public License for more details.
19: *
20: * You should have received a copy of the GNU Lesser General Public License
21: * along with this program; if not, write to the Free Software
22: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23: */
24:
25: import java.awt.Color;
26: import java.awt.Component;
27:
28: import javax.swing.BorderFactory;
29: import javax.swing.JLabel;
30: import javax.swing.JList;
31: import javax.swing.ListCellRenderer;
32:
33: class ManagerCellRenderer extends JLabel implements ListCellRenderer {
34:
35: public ManagerCellRenderer() {
36: // Don't paint behind the component
37: setOpaque(true);
38: }
39:
40: // Set the attributes of the
41: //class and return a reference
42: public Component getListCellRendererComponent(JList list,
43: Object value, // value to display
44: int index, // cell index
45: boolean iss, // is selected
46: boolean chf) // cell has focus?
47: {
48: // Set the text and color
49: //background for rendering
50: setText(((ListItem) value).getValue());
51: setBackground(((ListItem) value).getColor());
52:
53: // Set a border if the list
54: //item is selected
55: if (iss) {
56: setBorder(BorderFactory.createLineBorder(Color.blue, 2));
57: } else {
58: setBorder(BorderFactory.createLineBorder(list
59: .getBackground(), 2));
60: }
61: return this;
62: }
63: }
|