KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > zirc > gui > smiliesWindow > CustomCellRenderer


1 package zirc.gui.smiliesWindow ;
2
3 import java.awt.* ;
4 import javax.swing.* ;
5 import javax.swing.table.* ;
6
7 //zIrc, irc client.
8
// Copyright (C) 2004 CoolBytes(Stephane claret, Andre Aymon, Alban Zumofen) coolbytes@hotmail.com
9
//
10
// This program is free software; you can redistribute it and/or
11
// modify it under the terms of the GNU 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 General Public License for more details.
19

20 /**
21  * <p>Title: CustomCellRenderer</p>
22  * <p>Description: sert a rendre les smilies dans la table</p>
23  * <p>Copyright: Copyright (c) 2004</p>
24  * <p>Company: CoolBytes(Stephane claret, Andre Aymon, Alban Zumofen) coolbytes@hotmail.com</p>
25  * @version 1.0
26  */

27
28 public class CustomCellRenderer extends JLabel implements TableCellRenderer
29 {
30
31   private SmiliesCollection smiliesCollection ;
32
33   public CustomCellRenderer(SmiliesCollection smiliesCollection)
34   {
35     this.smiliesCollection = smiliesCollection ;
36   }
37
38   public Component getTableCellRendererComponent(JTable table,
39                                                  Object JavaDoc value,
40                                                  boolean isSelected,
41                                                  boolean hasFocus,
42                                                  int row, int column)
43   {
44     setText(smiliesCollection.getValueAt(row, column, 1).toString()) ;
45     setIcon((ImageIcon)smiliesCollection.getValueAt(row, column, 0)) ;
46
47     return this ;
48   }
49 }
50
Popular Tags