KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > clif > console > lib > gui > GraphCellRenderer


1 /*
2 * CLIF is a Load Injection Framework
3 * Copyright (C) 2003 France Telecom R&D
4 * Copyright (C) 2003 INRIA
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * CLIF $Name: $
21 *
22 * Contact: clif@objectweb.org
23 *
24 * @authors: Julien Buret
25 * @authors: Nicolas Droze
26 */

27 package org.objectweb.clif.console.lib.gui;
28
29 import java.awt.Component JavaDoc;
30
31 import javax.swing.JTable JavaDoc;
32 import javax.swing.table.DefaultTableCellRenderer JavaDoc;
33
34 public class GraphCellRenderer extends DefaultTableCellRenderer JavaDoc {
35
36     private InjectorsGraph[] allInjectors;
37
38     public GraphCellRenderer(InjectorsGraph[] allInjectors) {
39         this.allInjectors = allInjectors;
40     }
41
42     public Component JavaDoc getTableCellRendererComponent(
43         JTable JavaDoc table,
44         Object JavaDoc value,
45         boolean isSelected,
46         boolean hasFocus,
47         int row,
48         int column) {
49         super.getTableCellRendererComponent(
50             table,
51             value,
52             isSelected,
53             hasFocus,
54             row,
55             column);
56         for (int i = 0; i < allInjectors.length; i++) {
57             if (allInjectors[i].name.equals((String JavaDoc) value)) {
58                 this.setForeground(allInjectors[i].color);
59                 break;
60             }
61         }
62
63         return this;
64     }
65 }
Popular Tags