KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > table > TableColumnModel


1 /*
2  * @(#)TableColumnModel.java 1.25 04/05/05
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.swing.table;
9
10 import java.util.Enumeration JavaDoc;
11 import javax.swing.event.ChangeEvent JavaDoc;
12 import javax.swing.event.*;
13 import javax.swing.*;
14
15
16 /**
17  * Defines the requirements for a table column model object suitable for
18  * use with <code>JTable</code>.
19  *
20  * @version 1.25 05/05/04
21  * @author Alan Chung
22  * @author Philip Milne
23  * @see DefaultTableColumnModel
24  */

25 public interface TableColumnModel
26 {
27 //
28
// Modifying the model
29
//
30

31     /**
32      * Appends <code>aColumn</code> to the end of the
33      * <code>tableColumns</code> array.
34      * This method posts a <code>columnAdded</code>
35      * event to its listeners.
36      *
37      * @param aColumn the <code>TableColumn</code> to be added
38      * @see #removeColumn
39      */

40     public void addColumn(TableColumn JavaDoc aColumn);
41
42     /**
43      * Deletes the <code>TableColumn</code> <code>column</code> from the
44      * <code>tableColumns</code> array. This method will do nothing if
45      * <code>column</code> is not in the table's column list.
46      * This method posts a <code>columnRemoved</code>
47      * event to its listeners.
48      *
49      * @param column the <code>TableColumn</code> to be removed
50      * @see #addColumn
51      */

52     public void removeColumn(TableColumn JavaDoc column);
53     
54     /**
55      * Moves the column and its header at <code>columnIndex</code> to
56      * <code>newIndex</code>. The old column at <code>columnIndex</code>
57      * will now be found at <code>newIndex</code>. The column that used
58      * to be at <code>newIndex</code> is shifted left or right
59      * to make room. This will not move any columns if
60      * <code>columnIndex</code> equals <code>newIndex</code>. This method
61      * posts a <code>columnMoved</code> event to its listeners.
62      *
63      * @param columnIndex the index of column to be moved
64      * @param newIndex index of the column's new location
65      * @exception IllegalArgumentException if <code>columnIndex</code> or
66      * <code>newIndex</code>
67      * are not in the valid range
68      */

69     public void moveColumn(int columnIndex, int newIndex);
70
71     /**
72      * Sets the <code>TableColumn</code>'s column margin to
73      * <code>newMargin</code>. This method posts
74      * a <code>columnMarginChanged</code> event to its listeners.
75      *
76      * @param newMargin the width, in pixels, of the new column margins
77      * @see #getColumnMargin
78      */

79     public void setColumnMargin(int newMargin);
80     
81 //
82
// Querying the model
83
//
84

85     /**
86      * Returns the number of columns in the model.
87      * @return the number of columns in the model
88      */

89     public int getColumnCount();
90     
91     /**
92      * Returns an <code>Enumeration</code> of all the columns in the model.
93      * @return an <code>Enumeration</code> of all the columns in the model
94      */

95     public Enumeration JavaDoc<TableColumn JavaDoc> getColumns();
96
97     /**
98      * Returns the index of the first column in the table
99      * whose identifier is equal to <code>identifier</code>,
100      * when compared using <code>equals</code>.
101      *
102      * @param columnIdentifier the identifier object
103      * @return the index of the first table column
104      * whose identifier is equal to <code>identifier</code>
105      * @exception IllegalArgumentException if <code>identifier</code>
106      * is <code>null</code>, or no
107      * <code>TableColumn</code> has this
108      * <code>identifier</code>
109      * @see #getColumn
110      */

111     public int getColumnIndex(Object JavaDoc columnIdentifier);
112
113     /**
114      * Returns the <code>TableColumn</code> object for the column at
115      * <code>columnIndex</code>.
116      *
117      * @param columnIndex the index of the desired column
118      * @return the <code>TableColumn</code> object for
119      * the column at <code>columnIndex</code>
120      */

121     public TableColumn JavaDoc getColumn(int columnIndex);
122
123     /**
124      * Returns the width between the cells in each column.
125      * @return the margin, in pixels, between the cells
126      */

127     public int getColumnMargin();
128     
129     /**
130      * Returns the index of the column that lies on the
131      * horizontal point, <code>xPosition</code>;
132      * or -1 if it lies outside the any of the column's bounds.
133      *
134      * In keeping with Swing's separable model architecture, a
135      * TableColumnModel does not know how the table columns actually appear on
136      * screen. The visual presentation of the columns is the responsibility
137      * of the view/controller object using this model (typically JTable). The
138      * view/controller need not display the columns sequentially from left to
139      * right. For example, columns could be displayed from right to left to
140      * accomodate a locale preference or some columns might be hidden at the
141      * request of the user. Because the model does not know how the columns
142      * are laid out on screen, the given <code>xPosition</code> should not be
143      * considered to be a coordinate in 2D graphics space. Instead, it should
144      * be considered to be a width from the start of the first column in the
145      * model. If the column index for a given X coordinate in 2D space is
146      * required, <code>JTable.columnAtPoint</code> can be used instead.
147      *
148      * @return the index of the column; or -1 if no column is found
149      * @see javax.swing.JTable#columnAtPoint
150      */

151     public int getColumnIndexAtX(int xPosition);
152     
153     /**
154      * Returns the total width of all the columns.
155      * @return the total computed width of all columns
156      */

157     public int getTotalColumnWidth();
158
159 //
160
// Selection
161
//
162

163     /**
164      * Sets whether the columns in this model may be selected.
165      * @param flag true if columns may be selected; otherwise false
166      * @see #getColumnSelectionAllowed
167      */

168     public void setColumnSelectionAllowed(boolean flag);
169
170     /**
171      * Returns true if columns may be selected.
172      * @return true if columns may be selected
173      * @see #setColumnSelectionAllowed
174      */

175     public boolean getColumnSelectionAllowed();
176
177     /**
178      * Returns an array of indicies of all selected columns.
179      * @return an array of integers containing the indicies of all
180      * selected columns; or an empty array if nothing is selected
181      */

182     public int[] getSelectedColumns();
183
184     /**
185      * Returns the number of selected columns.
186      *
187      * @return the number of selected columns; or 0 if no columns are selected
188      */

189     public int getSelectedColumnCount();
190
191     /**
192      * Sets the selection model.
193      *
194      * @param newModel a <code>ListSelectionModel</code> object
195      * @see #getSelectionModel
196      */

197     public void setSelectionModel(ListSelectionModel newModel);
198     
199     /**
200      * Returns the current selection model.
201      *
202      * @return a <code>ListSelectionModel</code> object
203      * @see #setSelectionModel
204      */

205     public ListSelectionModel getSelectionModel();
206     
207 //
208
// Listener
209
//
210

211     /**
212      * Adds a listener for table column model events.
213      *
214      * @param x a <code>TableColumnModelListener</code> object
215      */

216     public void addColumnModelListener(TableColumnModelListener x);
217
218     /**
219      * Removes a listener for table column model events.
220      *
221      * @param x a <code>TableColumnModelListener</code> object
222      */

223     public void removeColumnModelListener(TableColumnModelListener x);
224 }
225
Popular Tags