KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > engine > sampleclient > gui > model > ServiceListRenderer


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: ServiceListRenderer.java 16:40:52 ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.engine.sampleclient.gui.model;
23
24 import java.awt.Component JavaDoc;
25
26 import javax.swing.JLabel JavaDoc;
27 import javax.swing.JList JavaDoc;
28 import javax.swing.ListCellRenderer JavaDoc;
29
30 /**
31  * CellRenderer for the list of services
32  *
33  * @author ddesjardins - eBMWebsourcing
34  */

35 public class ServiceListRenderer implements ListCellRenderer JavaDoc {
36
37     private ListCellRenderer JavaDoc listCellRenderer;
38
39     public ServiceListRenderer(ListCellRenderer JavaDoc defaultCellRenderer) {
40         this.listCellRenderer = defaultCellRenderer;
41     }
42
43     public Component JavaDoc getListCellRendererComponent(JList JavaDoc list, Object JavaDoc value,
44         int index, boolean isSelected, boolean cellHasFocus) {
45         JLabel JavaDoc component = (JLabel JavaDoc) listCellRenderer
46             .getListCellRendererComponent(list, value, index, isSelected,
47                 cellHasFocus);
48         if (value instanceof JLabel JavaDoc) {
49             component.setText(((JLabel JavaDoc) value).getText());
50             component.setToolTipText(((JLabel JavaDoc) value).getToolTipText());
51         }
52         return component;
53     }
54
55 }
56
Popular Tags