Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

TEvenOddColoringTableCellRenderer.java

00001 /*
00002 *  Name:      TEvenOddColoringTableCellRenderer.java
00003 *  Author:    Rafael Jesus Alcantara Perez
00004 *  Summary:   Table tree cell renderer that displays different colors depending
00005 *             on row evenness
00006 *  Date:      $Date: 2003/09/27 12:45:07 $
00007 *  Revision:  $Revision: 1.2 $
00008 *
00009 *  Copyright (C) 2003  Rafael Jesus Alcantara Perez <rafa@dedalo-ing.com>
00010 *
00011 *  This program is free software; you can redistribute it and/or modify
00012 *  it under the terms of the GNU General Public License as published by
00013 *  the Free Software Foundation; either version 2 of the License, or
00014 *  (at your option) any later version.
00015 *
00016 *  This program is distributed in the hope that it will be useful,
00017 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 *  GNU General Public License for more details.
00020 *
00021 *  You should have received a copy of the GNU General Public License
00022 *  along with this program; if not, write to the Free Software
00023 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00024 *  MA 02111-1307, USA.
00025 */
00026 
00028 package org.mpcl.nui;
00029 
00030 import java.awt.Color;
00031 import java.awt.Component;
00032 import javax.swing.JTable;
00033 import javax.swing.table.DefaultTableCellRenderer;
00034 
00035 
00037 public class TEvenOddColoringTableCellRenderer extends DefaultTableCellRenderer
00038 {
00039 
00041   private Color   tEvenRowColor;
00042 
00044   private Color   tOddRowColor;
00045 
00046 
00047   //
00048   //  C O N S T R U C T O R S
00049   //
00050 
00056   public TEvenOddColoringTableCellRenderer (Color tEVEN_ROW_COLOR, Color tODD_ROW_COLOR)
00057   {
00058     tEvenRowColor = tEVEN_ROW_COLOR;
00059     tOddRowColor  = tODD_ROW_COLOR;
00060   }
00061 
00062 
00063   //
00064   //  S E L E C T O R S
00065   //
00066 
00080   public Component getTableCellRendererComponent ( JTable  tTABLE       ,
00081                                                    Object  tVALUE       ,
00082                                                    boolean gIS_SELECTED ,
00083                                                    boolean gHAS_FOCUS   ,
00084                                                    int     iROW         ,
00085                                                    int     iCOLUMN      )
00086   {
00087 
00088     super.getTableCellRendererComponent (tTABLE, tVALUE, gIS_SELECTED, gHAS_FOCUS, iROW, iCOLUMN);
00089     if ( !gIS_SELECTED )
00090     {
00091       if ( (iROW % 2) == 1 )
00092       {
00093         setBackground (tEvenRowColor);
00094       }
00095       else
00096       {
00097         if ( tOddRowColor == null )
00098         {
00099           tOddRowColor = tTABLE.getBackground();
00100         }
00101         setBackground (tOddRowColor);
00102       }
00103     }
00104     return this;
00105 
00106   }  // getTableCellRendererComponent()
00107 
00108 }  // class TEvenOddColoringTableCellRenderer

Generated on Mon Oct 13 02:35:24 2003 for MPCL by doxygen1.2.18