BooleanRenderer.java
01 /*
02  *  Copyright (c) 1995-2010, The University of Sheffield. See the file
03  *  COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
04  *
05  *  This file is part of GATE (see http://gate.ac.uk/), and is free
06  *  software, licenced under the GNU Library General Public License,
07  *  Version 2, June 1991 (in the distribution as file licence.html,
08  *  and also available at http://gate.ac.uk/gate/licence.html).
09  *
10  *  Valentin Tablan 23/01/2001
11  *
12  *  $Id: BooleanRenderer.java 12006 2009-12-01 17:24:28Z thomas_heitz $
13  *
14  */
15 package gate.gui;
16 
17 import java.awt.Component;
18 
19 import javax.swing.JTable;
20 import javax.swing.table.DefaultTableCellRenderer;
21 
22 /**
23  * A {@link javax.swing.table.TableCellRenderer} used for Booleans
24  */
25 public class BooleanRenderer extends DefaultTableCellRenderer {
26   public Component getTableCellRendererComponent(JTable table,
27                                                  Object value,
28                                                  boolean isSelected,
29                                                  boolean hasFocus,
30                                                  int row,
31                                                  int column){
32     Component comp = super.getTableCellRendererComponent(table,
33                                                          "",
34                                                          isSelected, hasFocus,
35                                                          row, column);
36     if(value instanceof Boolean &&
37        value != null &&
38        ((Boolean)value).booleanValue()){
39       setIcon(MainFrame.getIcon("tick"));
40 //      setIcon(MainFrame.getIcon((isSelected) ? "tick_white" : "tick"));
41     else {
42       setIcon(null);
43     }
44 
45     return this;
46   }//public Component getTableCellRendererComponent
47 }//class BooleanRenderer extends DefaultTableCellRenderer