01: /*
02: * Created on 01/01/2004
03: *
04: * Swing Components - visit http://sf.net/projects/gfd
05: *
06: * Copyright (C) 2004 Igor Regis da Silva Simões
07: *
08: * This program is free software; you can redistribute it and/or
09: * modify it under the terms of the GNU General Public License
10: * as published by the Free Software Foundation; either version 2
11: * of the License, or (at your option) any later version.
12: *
13: * This program is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: * GNU General Public License for more details.
17: *
18: * You should have received a copy of the GNU General Public License
19: * along with this program; if not, write to the Free Software
20: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21: *
22: */
23:
24: package br.com.gfpshare.beans.table;
25:
26: import java.awt.Color;
27: import java.awt.Component;
28:
29: import javax.swing.JTable;
30: import javax.swing.border.BevelBorder;
31: import javax.swing.table.DefaultTableCellRenderer;
32:
33: /**
34: * Esta classe exerce a funçao de um TableCellRenderer, porém formatando a aparência da célula, para que a
35: * tabela fique listrada em tons anternados de cinza
36: *
37: * @author Igor Regis da Silva Simões
38: * @created 01/01/2004
39: */
40: public class TableCellRendererListradoCinza extends
41: DefaultTableCellRenderer {
42:
43: /** Cria uma novo instância de TableCellDiasMesRender */
44: public TableCellRendererListradoCinza() {
45: super ();
46: }
47:
48: /**
49: * Sobrescreve o método da superclasse para retornar um renderer formatado, conforme descrito acima
50: *
51: * @param table JTable Tabela que será configurada por este renderer
52: * @param value Object Valor que será exibido pelo renderer
53: * @param isSelected boolean Indicando se a célula está selecionada
54: * @param hasFocus boolean indicando se a célual possui o foco
55: * @param row int Linha da célula
56: * @param column int Coluna da célula
57: * @return Retorna o Compoment responsável por renderizar o valor da célula
58: */
59: @Override
60: public Component getTableCellRendererComponent(JTable table,
61: Object value, boolean isSelected, boolean hasFocus,
62: int row, int column) {
63:
64: setValue(value);
65:
66: if (isSelected)
67: setBorder(new BevelBorder(BevelBorder.LOWERED, new Color(
68: 180, 180, 255), new Color(55, 55, 255)));
69: else
70: setBorder(null);
71:
72: if (value != null && value instanceof String)
73: try {
74: if (Double.parseDouble((String) value) < 0)
75: setForeground(Color.RED);
76: else
77: setForeground(Color.BLACK);
78: } catch (NumberFormatException nfe) {
79: //Não Fazemos nada
80: }
81: return this;
82:
83: }
84:
85: }
|