1 |
/* TableColumn.java -- |
/* TableColumn.java -- |
2 |
Copyright (C) 2002, 2004 Free Software Foundation, Inc. |
Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
38 |
|
|
39 |
package javax.swing.table; |
package javax.swing.table; |
40 |
|
|
41 |
|
import java.beans.PropertyChangeEvent; |
42 |
import java.beans.PropertyChangeListener; |
import java.beans.PropertyChangeListener; |
43 |
import java.io.Serializable; |
import java.io.Serializable; |
44 |
|
|
45 |
import javax.swing.event.SwingPropertyChangeSupport; |
import javax.swing.event.SwingPropertyChangeSupport; |
46 |
|
|
47 |
/** |
/** |
48 |
* TableColumn |
* Represents the attributes of a column in a table, including the column index, |
49 |
|
* width, minimum width, preferred width and maximum width. |
50 |
|
* |
51 |
* @author Andrew Selkirk |
* @author Andrew Selkirk |
52 |
* @version 1.0 |
* @version 1.0 |
53 |
*/ |
*/ |
57 |
static final long serialVersionUID = -6113660025878112608L; |
static final long serialVersionUID = -6113660025878112608L; |
58 |
|
|
59 |
/** |
/** |
60 |
* COLUMN_WIDTH_PROPERTY |
* The name for the <code>columnWidth</code> property. Note that the typo |
61 |
|
* in the name value is deliberate, to match the specification. |
62 |
*/ |
*/ |
63 |
public static final String COLUMN_WIDTH_PROPERTY = "columWidth"; |
public static final String COLUMN_WIDTH_PROPERTY = "columWidth"; |
64 |
|
|
65 |
/** |
/** |
66 |
* HEADER_VALUE_PROPERTY |
* The name for the <code>headerValue</code> property. |
67 |
*/ |
*/ |
68 |
public static final String HEADER_VALUE_PROPERTY = "headerValue"; |
public static final String HEADER_VALUE_PROPERTY = "headerValue"; |
69 |
|
|
70 |
/** |
/** |
71 |
* HEADER_RENDERER_PROPERTY |
* The name for the <code>headerRenderer</code> property. |
72 |
*/ |
*/ |
73 |
public static final String HEADER_RENDERER_PROPERTY = "headerRenderer"; |
public static final String HEADER_RENDERER_PROPERTY = "headerRenderer"; |
74 |
|
|
75 |
/** |
/** |
76 |
* CELL_RENDERER_PROPERTY |
* The name for the <code>cellRenderer</code> property. |
77 |
*/ |
*/ |
78 |
public static final String CELL_RENDERER_PROPERTY = "cellRenderer"; |
public static final String CELL_RENDERER_PROPERTY = "cellRenderer"; |
79 |
|
|
80 |
/** |
/** |
81 |
* modelIndex |
* The index of the corresponding column in the table model. |
82 |
*/ |
*/ |
83 |
protected int modelIndex; |
protected int modelIndex; |
84 |
|
|
85 |
/** |
/** |
86 |
* identifier |
* The identifier for the column. |
87 |
*/ |
*/ |
88 |
protected Object identifier; |
protected Object identifier; |
89 |
|
|
90 |
/** |
/** |
91 |
* width |
* The width. |
92 |
*/ |
*/ |
93 |
protected int width; |
protected int width; |
94 |
|
|
95 |
/** |
/** |
96 |
* minWidth |
* The minimum width. |
97 |
*/ |
*/ |
98 |
protected int minWidth = 15; |
protected int minWidth = 15; |
99 |
|
|
100 |
/** |
/** |
101 |
* preferredWidth |
* The preferred width. |
102 |
*/ |
*/ |
103 |
private int preferredWidth; |
private int preferredWidth; |
104 |
|
|
105 |
/** |
/** |
106 |
* maxWidth |
* The maximum width. |
107 |
*/ |
*/ |
108 |
protected int maxWidth = Integer.MAX_VALUE; |
protected int maxWidth = Integer.MAX_VALUE; |
109 |
|
|
113 |
protected TableCellRenderer headerRenderer; |
protected TableCellRenderer headerRenderer; |
114 |
|
|
115 |
/** |
/** |
116 |
* headerValue |
* The header value. |
117 |
*/ |
*/ |
118 |
protected Object headerValue; |
protected Object headerValue; |
119 |
|
|
146 |
new SwingPropertyChangeSupport(this); |
new SwingPropertyChangeSupport(this); |
147 |
|
|
148 |
/** |
/** |
149 |
* Constructor TableColumn |
* Creates a new <code>TableColumn</code> that maps to column 0 in the |
150 |
|
* related table model. The default width is <code>75</code> units. |
151 |
*/ |
*/ |
152 |
public TableColumn() |
public TableColumn() |
153 |
{ |
{ |
155 |
} |
} |
156 |
|
|
157 |
/** |
/** |
158 |
* Constructor TableColumn |
* Creates a new <code>TableColumn</code> that maps to the specified column |
159 |
|
* in the related table model. The default width is <code>75</code> units. |
160 |
* |
* |
161 |
* @param modelIndex the index of the column in the model |
* @param modelIndex the index of the column in the model |
162 |
*/ |
*/ |
166 |
} |
} |
167 |
|
|
168 |
/** |
/** |
169 |
* Constructor TableColumn |
* Creates a new <code>TableColumn</code> that maps to the specified column |
170 |
|
* in the related table model, and has the specified <code>width</code>. |
171 |
* |
* |
172 |
* @param modelIndex the index of the column in the model |
* @param modelIndex the index of the column in the model |
173 |
* @param width the width |
* @param width the width |
178 |
} |
} |
179 |
|
|
180 |
/** |
/** |
181 |
* Constructor TableColumn |
* Creates a new <code>TableColumn</code> that maps to the specified column |
182 |
|
* in the related table model, and has the specified <code>width</code>, |
183 |
|
* <code>cellRenderer</code> and <code>cellEditor</code>. |
184 |
* |
* |
185 |
* @param modelIndex the index of the column in the model |
* @param modelIndex the index of the column in the model |
186 |
* @param width the width |
* @param width the width |
187 |
* @param cellRenderer the cell renderer |
* @param cellRenderer the cell renderer (<code>null</code> permitted). |
188 |
* @param cellEditor the cell editor |
* @param cellEditor the cell editor (<code>null</code> permitted). |
189 |
*/ |
*/ |
190 |
public TableColumn(int modelIndex, int width, |
public TableColumn(int modelIndex, int width, |
191 |
TableCellRenderer cellRenderer, TableCellEditor cellEditor) |
TableCellRenderer cellRenderer, TableCellEditor cellEditor) |
239 |
} |
} |
240 |
|
|
241 |
/** |
/** |
242 |
* setModelIndex |
* Sets the index of the column in the related {@link TableModel} that this |
243 |
|
* <code>TableColumn</code> maps to. |
244 |
* |
* |
245 |
* @param modelIndex the index to set |
* @param modelIndex the column index in the model. |
246 |
*/ |
*/ |
247 |
public void setModelIndex(int modelIndex) |
public void setModelIndex(int modelIndex) |
248 |
{ |
{ |
250 |
} |
} |
251 |
|
|
252 |
/** |
/** |
253 |
* getModelIndex |
* Returns the index of the column in the related {@link TableModel} that |
254 |
|
* this <code>TableColumn</code> maps to. |
255 |
* |
* |
256 |
* @return the model index |
* @return the model index |
257 |
*/ |
*/ |
261 |
} |
} |
262 |
|
|
263 |
/** |
/** |
264 |
* setIdentifier |
* Sets the identifier for the column. |
265 |
* |
* |
266 |
* @param identifier the identifier |
* @param identifier the identifier |
267 |
*/ |
*/ |
271 |
} |
} |
272 |
|
|
273 |
/** |
/** |
274 |
* getIdentifier |
* Returns the identifier for the column, or {@link #getHeaderValue()} if the |
275 |
|
* identifier is <code>null</code>. |
276 |
* |
* |
277 |
* @return the identifier |
* @return The identifier (or {@link #getHeaderValue()} if the identifier is |
278 |
|
* <code>null</code>). |
279 |
*/ |
*/ |
280 |
public Object getIdentifier() |
public Object getIdentifier() |
281 |
{ |
{ |
285 |
} |
} |
286 |
|
|
287 |
/** |
/** |
288 |
* setHeaderValue |
* Sets the header value and sends a {@link PropertyChangeEvent} to all |
289 |
|
* registered listeners. The header value property uses the name |
290 |
|
* {@link #HEADER_VALUE_PROPERTY}. |
291 |
* |
* |
292 |
* @param headerValue the value of the header |
* @param headerValue the value of the header |
293 |
*/ |
*/ |
302 |
} |
} |
303 |
|
|
304 |
/** |
/** |
305 |
* getHeaderValue |
* Returns the header value. |
306 |
* |
* |
307 |
* @return the value of the header |
* @return the value of the header |
308 |
*/ |
*/ |
314 |
/** |
/** |
315 |
* setHeaderRenderer |
* setHeaderRenderer |
316 |
* |
* |
317 |
* @param headerRenderer the renderer to se |
* @param renderer the renderer to use |
318 |
*/ |
*/ |
319 |
public void setHeaderRenderer(TableCellRenderer renderer) |
public void setHeaderRenderer(TableCellRenderer renderer) |
320 |
{ |
{ |
337 |
} |
} |
338 |
|
|
339 |
/** |
/** |
340 |
* setCellRenderer |
* Sets the renderer for cells in this column and sends a |
341 |
|
* {@link PropertyChangeEvent} to all registered listeners. |
342 |
* |
* |
343 |
* @param cellRenderer the cell renderer |
* @param renderer the cell renderer (<code>null</code> permitted). |
344 |
*/ |
*/ |
345 |
public void setCellRenderer(TableCellRenderer renderer) |
public void setCellRenderer(TableCellRenderer renderer) |
346 |
{ |
{ |
354 |
} |
} |
355 |
|
|
356 |
/** |
/** |
357 |
* getCellRenderer |
* Returns the renderer for the table cells in this column. |
358 |
* |
* |
359 |
* @return the cell renderer |
* @return The cell renderer. |
360 |
*/ |
*/ |
361 |
public TableCellRenderer getCellRenderer() |
public TableCellRenderer getCellRenderer() |
362 |
{ |
{ |
441 |
} |
} |
442 |
|
|
443 |
/** |
/** |
444 |
* setMinWidth |
* Sets the minimum width for the column and, if necessary, updates the |
445 |
|
* <code>width</code> and <code>preferredWidth</code>. |
446 |
* |
* |
447 |
* @param minWidth the minium width |
* @param minWidth the minimum width |
448 |
*/ |
*/ |
449 |
public void setMinWidth(int minWidth) |
public void setMinWidth(int minWidth) |
450 |
{ |
{ |
454 |
} |
} |
455 |
|
|
456 |
/** |
/** |
457 |
* getMinWidth |
* Returns the <code>TableColumn</code>'s minimum width. |
458 |
* |
* |
459 |
* @return the minimum width |
* @return The minimum width. |
460 |
*/ |
*/ |
461 |
public int getMinWidth() |
public int getMinWidth() |
462 |
{ |
{ |
464 |
} |
} |
465 |
|
|
466 |
/** |
/** |
467 |
* setMaxWidth |
* Sets the maximum width and, if necessary, updates the <code>width</code> |
468 |
|
* and <code>preferredWidth</code>. |
469 |
* |
* |
470 |
* @param maxWidth the maximum width |
* @param maxWidth the maximum width |
471 |
*/ |
*/ |
477 |
} |
} |
478 |
|
|
479 |
/** |
/** |
480 |
* getMaxWidth |
* Returns the maximum width. |
481 |
* @return the maximim width |
* |
482 |
|
* @return The maximum width. |
483 |
*/ |
*/ |
484 |
public int getMaxWidth() |
public int getMaxWidth() |
485 |
{ |
{ |
517 |
} |
} |
518 |
|
|
519 |
/** |
/** |
520 |
* disableResizedPosting |
* This method is empty, unused and deprecated. |
|
* |
|
521 |
* @deprecated 1.3 |
* @deprecated 1.3 |
522 |
*/ |
*/ |
523 |
public void disableResizedPosting() |
public void disableResizedPosting() |
526 |
} |
} |
527 |
|
|
528 |
/** |
/** |
529 |
* enableResizedPosting |
* This method is empty, unused and deprecated. |
|
* |
|
530 |
* @deprecated 1.3 |
* @deprecated 1.3 |
531 |
*/ |
*/ |
532 |
public void enableResizedPosting() |
public void enableResizedPosting() |
535 |
} |
} |
536 |
|
|
537 |
/** |
/** |
538 |
* addPropertyChangeListener |
* Adds a property change listener. |
539 |
* @param listener the listener to all |
* |
540 |
|
* @param listener the listener to add |
541 |
*/ |
*/ |
542 |
public synchronized void addPropertyChangeListener(PropertyChangeListener listener) |
public synchronized void addPropertyChangeListener(PropertyChangeListener listener) |
543 |
{ |
{ |
554 |
} |
} |
555 |
|
|
556 |
/** |
/** |
557 |
|
* Returns the property change listeners for this <code>TableColumn</code>. |
558 |
* @since 1.4 |
* @since 1.4 |
559 |
*/ |
*/ |
560 |
public PropertyChangeListener[] getPropertyChangeListeners() |
public PropertyChangeListener[] getPropertyChangeListeners() |