KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > table > SDefaultTableCellRenderer


1 /*
2  * $Id: SDefaultTableCellRenderer.java,v 1.4 2004/12/01 07:54:27 hengels Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings.table;
15
16 import org.wings.SComponent;
17 import org.wings.SIcon;
18 import org.wings.SLabel;
19 import org.wings.STable;
20
21 /**
22  * @author <a HREF="mailto:holger.engels@mercatis.de">Holger Engels</a>
23  * @version $Revision: 1.4 $
24  */

25 public class SDefaultTableCellRenderer
26         extends SLabel
27         implements STableCellRenderer
28 {
29     SIcon editIcon;
30
31     public SIcon getEditIcon() {
32         return editIcon;
33     }
34
35     public void setEditIcon(SIcon editIcon) {
36         this.editIcon = editIcon;
37     }
38
39     public SComponent getTableCellRendererComponent(STable table,
40                                                     Object JavaDoc value,
41                                                     boolean selected,
42                                                     int row,
43                                                     int col) {
44         setText(null);
45         setIcon(null);
46
47         if (value == null) {
48             if (editIcon != null && table.isCellEditable(row, col))
49                 setIcon(editIcon);
50         }
51         else if (value instanceof SIcon)
52             setIcon((SIcon)value);
53         else if (value instanceof SComponent)
54             return (SComponent)value;
55         else
56             setText(value.toString());
57
58         return this;
59     }
60 }
61
Popular Tags