View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  package org.xnap.gui.table;
21  
22  import javax.swing.table.TableCellRenderer;
23  import javax.swing.table.TableColumn;
24  
25  public class Column extends TableColumn
26  {
27  
28      //--- Constant(s) ---
29  
30      //--- Data Field(s) ---
31  
32      protected Class dataType;
33      protected String name;
34      protected boolean visible = false;
35      private String key;
36  
37      //--- Constructor(s) ---
38  
39      public Column(String key, String name, Class dataType, TableCellRenderer r)
40      {
41  		super(0, 50, r, null);
42  
43  		this.name = name;
44  		this.dataType = dataType;
45  		this.key = key;
46      }
47  
48      public Column(String name, Class dataType, TableCellRenderer r)
49      {
50  		this(name, name, dataType, r);
51      }
52  
53      public Column(String key, String name, Class dataType)
54      {
55  		this(key, name, dataType, null);
56      }
57  
58      public Column(String name, Class dataType)
59      {
60  		this(name, name, dataType, null);
61      }
62  
63      //--- Method(s) ---
64  
65      /***
66       * Returns the key. Used to store the "is visible" preference.
67       */
68      public String getKey()
69      {
70  		return key;
71      }
72  
73      public Class getDataType()
74      {
75  		return dataType;
76      }
77  
78      public Object getHeaderValue() 
79      {
80  		return name;
81      }
82  
83      public String getName()
84      {
85  		return name;
86      }
87  
88      public boolean isVisible()
89      {
90  		return visible;
91      }
92  
93      public void setVisible(boolean newValue) 
94      {
95  		visible = newValue;
96      }
97  
98      public String toString()
99      {
100 		return name;
101     }
102 
103 }