KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > applications > jmail > base > ColorableCellRenderer


1 package org.lucane.applications.jmail.base;
2
3 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
4  * This file is part of JMail *
5  * Copyright (C) 2002-2003 Yvan Norsa <norsay@wanadoo.fr> *
6  * *
7  * JMail is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * any later version. *
11  * *
12  * JMail is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License along *
18  * with JMail; if not, write to the Free Software Foundation, Inc., *
19  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20  * *
21  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

22
23 import java.awt.*;
24 import java.text.*;
25 import java.util.*;
26 import javax.mail.*;
27 import javax.swing.*;
28 import javax.swing.table.*;
29
30 /** This class is used to display the messages list. It allows to colorize mails and also to display dates according Locale */
31 final class ColorableCellRenderer extends DefaultTableCellRenderer
32 {
33     /** DateFormat used to display dates */
34     private DateFormat df;
35     private MainPanel parent;
36
37     /** Constructor
38      * @param df the <code>DateFormat</code> used
39      * @param parent the calling panel
40      */

41     ColorableCellRenderer(DateFormat df, MainPanel parent)
42     {
43     super();
44     this.df = df;
45     this.parent = parent;
46     }
47
48     /** TODO : put the DefaultTableCellRenderer.getTableCellRendererComponent() description here */
49     public Component getTableCellRendererComponent(JTable table, Object JavaDoc value, boolean isSelected, boolean hasFocus, int row, int column)
50     {
51     DefaultTableCellRenderer renderer = (DefaultTableCellRenderer)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
52
53     if(parent.isFlagSet(row, Flags.Flag.ANSWERED))
54         renderer.setForeground(Color.green);
55
56     else if(!parent.isFlagSet(row, Flags.Flag.SEEN))
57         renderer.setFont(new Font(null, Font.BOLD, 12));
58
59     else
60         renderer.setForeground(Color.black);
61
62     if(value instanceof Date)
63         setText(df.format(value));
64     
65     return(renderer);
66     }
67 }
68
Popular Tags