KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > aspects > gui > swing > ToStringTableCellRenderer


1 /*
2   Copyright (C) 2003 Laurent Martelli <laurent@aopsys.com>
3   
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful, but
10   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 program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17   USA */

18
19 package org.objectweb.jac.aspects.gui.swing;
20
21 import java.awt.Component JavaDoc;
22 import javax.swing.JLabel JavaDoc;
23 import javax.swing.table.TableCellRenderer JavaDoc;
24 import org.apache.log4j.Logger;
25 import org.objectweb.jac.aspects.gui.GuiAC;
26
27 public class ToStringTableCellRenderer extends JLabel JavaDoc implements TableCellRenderer JavaDoc
28 {
29     static Logger logger = Logger.getLogger("gui.table");
30
31     public ToStringTableCellRenderer()
32     {}
33
34     public Component JavaDoc getTableCellRendererComponent(
35         javax.swing.JTable JavaDoc table, Object JavaDoc value,
36         boolean isSelected, boolean hasFocus,
37         int row, int column)
38     {
39         logger.debug(
40             "ToStringTableCellRenderer.getTableCellRendererComponent("+
41             row+","+column+","+isSelected+")");
42
43         setOpaque(true); // so that the background is really drawn
44

45         if (isSelected) {
46             setForeground(table.getSelectionForeground());
47             setBackground(table.getSelectionBackground());
48         } else {
49             setForeground(table.getForeground());
50             setBackground(table.getBackground());
51         }
52         setFont(null);
53
54         setText(GuiAC.toString(value));
55
56         return this;
57     }
58
59 }
60
Popular Tags