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