1 package net.sf.xframe.swing.table;
2
3 import java.awt.Color;
4 import java.awt.Component;
5 import java.awt.Dimension;
6 import java.awt.HeadlessException;
7 import java.awt.Point;
8 import java.awt.Rectangle;
9 import java.awt.event.MouseEvent;
10 import java.util.EventObject;
11
12 import javax.accessibility.AccessibleContext;
13 import javax.swing.ListSelectionModel;
14 import javax.swing.event.ChangeEvent;
15 import javax.swing.event.ListSelectionEvent;
16 import javax.swing.event.TableColumnModelEvent;
17 import javax.swing.event.TableModelEvent;
18 import javax.swing.plaf.TableUI;
19 import javax.swing.table.TableCellEditor;
20 import javax.swing.table.TableCellRenderer;
21 import javax.swing.table.TableColumn;
22 import javax.swing.table.TableColumnModel;
23 import javax.swing.table.TableModel;
24
25 /***
26 * @author KurtR
27 *
28 * To change the template for this generated type comment go to
29 * Window>Preferences>Java>Code Generation>Code and Comments
30 */
31 public interface Table {
32 /*** Do not adjust column widths automatically; use a scrollbar. */
33 int AUTO_RESIZE_OFF = 0;
34
35 /*** When a column is adjusted in the UI, adjust the next column the opposite way. */
36 int AUTO_RESIZE_NEXT_COLUMN = 1;
37
38 /*** During UI adjustment, change subsequent columns to preserve the total width;
39 * this is the default behavior. */
40 int AUTO_RESIZE_SUBSEQUENT_COLUMNS = 2;
41
42 /*** During all resize operations, apply adjustments to the last column only. */
43 int AUTO_RESIZE_LAST_COLUMN = 3;
44
45 /*** During all resize operations, proportionately resize all columns. */
46 int AUTO_RESIZE_ALL_COLUMNS = 4;
47
48 /***
49 * Calls the <code>configureEnclosingScrollPane</code> method.
50 *
51 * @see #configureEnclosingScrollPane
52 */
53 void addNotify();
54
55 /***
56 * Calls the <code>unconfigureEnclosingScrollPane</code> method.
57 *
58 * @see #unconfigureEnclosingScrollPane
59 */
60 void removeNotify();
61
62 /***
63 * Sets the <code>tableHeader</code> working with this <code>JTable</code> to <code>newHeader</code>.
64 * It is legal to have a <code>null</code> <code>tableHeader</code>.
65 *
66 * @param tableHeader new tableHeader
67 * @see #getTableHeader
68 */
69 void setTableHeader(JXTableHeader tableHeader);
70
71 /***
72 * Returns the <code>tableHeader</code> used by this <code>JXTable</code>.
73 *
74 * @return the <code>tableHeader</code> used by this table
75 * @see #setTableHeader
76 */
77 JXTableHeader getTableHeader();
78
79 /***
80 * Sets the height, in pixels, of all cells to <code>rowHeight</code>,
81 * revalidates, and repaints.
82 * The height of the cells will be equal to the row height minus
83 * the row margin.
84 *
85 * @param rowHeight new row height
86 * @exception IllegalArgumentException if <code>rowHeight</code> is
87 * less than 1
88 * @see #getRowHeight
89 * @beaninfo
90 * bound: true
91 * description: The height of the specified row.
92 */
93 void setRowHeight(int rowHeight) throws IllegalArgumentException;
94
95 /***
96 * Returns the height of a table row, in pixels.
97 * The default row height is 16.0.
98 *
99 * @return the height in pixels of a table row
100 * @see #setRowHeight
101 */
102 int getRowHeight();
103
104 /***
105 * Sets the height for <code>row</code> to <code>rowHeight</code>,
106 * revalidates, and repaints. The height of the cells in this row
107 * will be equal to the row height minus the row margin.
108 *
109 * @param row the row whose height is being
110 changed
111 * @param rowHeight new row height, in pixels
112 * @exception IllegalArgumentException if <code>rowHeight</code> is
113 * less than 1
114 * @beaninfo
115 * bound: true
116 * description: The height in pixels of the cells in <code>row</code>
117 */
118 void setRowHeight(int row, int rowHeight) throws IllegalArgumentException;
119
120 /***
121 * Returns the height, in pixels, of the cells in <code>row</code>.
122 * @param row the row whose height is to be returned
123 * @return the height, in pixels, of the cells in the row
124 */
125 int getRowHeight(int row);
126
127 /***
128 * Sets the amount of empty space between cells in adjacent rows.
129 *
130 * @param rowMargin the number of pixels between cells in a row
131 * @see #getRowMargin
132 * @beaninfo
133 * bound: true
134 * description: The amount of space between cells.
135 */
136 void setRowMargin(int rowMargin);
137
138 /***
139 * Gets the amount of empty space, in pixels, between cells. Equivalent to:
140 * <code>getIntercellSpacing().height</code>.
141 * @return the number of pixels between cells in a row
142 *
143 * @see #setRowMargin
144 */
145 int getRowMargin();
146
147 /***
148 * Sets the <code>rowMargin</code> and the <code>columnMargin</code> --
149 * the height and width of the space between cells -- to
150 * <code>intercellSpacing</code>.
151 *
152 * @param intercellSpacing a <code>Dimension</code>
153 * specifying the new width
154 * and height between cells
155 * @see #getIntercellSpacing
156 * @beaninfo
157 * description: The spacing between the cells,
158 * drawn in the background color of the JXTable.
159 */
160 void setIntercellSpacing(Dimension intercellSpacing);
161
162 /***
163 * Returns the horizontal and vertical space between cells.
164 * The default spacing is (1, 1), which provides room to draw the grid.
165 *
166 * @return the horizontal and vertical spacing between cells
167 * @see #setIntercellSpacing
168 */
169 Dimension getIntercellSpacing();
170
171 /***
172 * Sets the color used to draw grid lines to <code>gridColor</code> and redisplays.
173 * The default color is look and feel dependent.
174 *
175 * @param gridColor the new color of the grid lines
176 * @exception IllegalArgumentException if <code>gridColor</code> is <code>null</code>
177 * @see #getGridColor
178 * @beaninfo
179 * bound: true
180 * description: The grid color.
181 */
182 void setGridColor(Color gridColor) throws IllegalArgumentException;
183
184 /***
185 * Returns the color used to draw grid lines.
186 * The default color is look and feel dependent.
187 *
188 * @return the color used to draw grid lines
189 * @see #setGridColor
190 */
191 Color getGridColor();
192
193 /***
194 * Sets whether the table draws grid lines around cells.
195 * If <code>showGrid</code> is true it does; if it is false it doesn't.
196 * There is no <code>getShowGrid</code> method as this state is held
197 * in two variables -- <code>showHorizontalLines</code> and <code>showVerticalLines</code> --
198 * each of which can be queried independently.
199 *
200 * @param showGrid true if table view should draw grid lines
201 *
202 * @see #setShowVerticalLines
203 * @see #setShowHorizontalLines
204 * @beaninfo
205 * description: The color used to draw the grid lines.
206 */
207 void setShowGrid(boolean showGrid);
208
209 /***
210 * Sets whether the table draws horizontal lines between cells.
211 * If <code>showHorizontalLines</code> is true it does; if it is false it doesn't.
212 *
213 * @param showHorizontalLines true if table view should draw horizontal lines
214 * @see #getShowHorizontalLines
215 * @see #setShowGrid
216 * @see #setShowVerticalLines
217 * @beaninfo
218 * bound: true
219 * description: Whether horizontal lines should be drawn in between the cells.
220 */
221 void setShowHorizontalLines(boolean showHorizontalLines);
222
223 /***
224 * Sets whether the table draws vertical lines between cells.
225 * If <code>showVerticalLines</code> is true it does; if it is false it doesn't.
226 *
227 * @param showVerticalLines true if table view should draw vertical lines
228 * @see #getShowVerticalLines
229 * @see #setShowGrid
230 * @see #setShowHorizontalLines
231 * @beaninfo
232 * bound: true
233 * description: Whether vertical lines should be drawn in between the cells.
234 */
235 void setShowVerticalLines(boolean showVerticalLines);
236
237 /***
238 * Returns true if the table draws horizontal lines between cells, false if it
239 * doesn't. The default is true.
240 *
241 * @return true if the table draws horizontal lines between cells, false if it
242 * doesn't
243 * @see #setShowHorizontalLines
244 */
245 boolean getShowHorizontalLines();
246
247 /***
248 * Returns true if the table draws vertical lines between cells, false if it
249 * doesn't. The default is true.
250 *
251 * @return true if the table draws vertical lines between cells, false if it
252 * doesn't
253 * @see #setShowVerticalLines
254 */
255 boolean getShowVerticalLines();
256
257 /***
258 * Sets the table's auto resize mode when the table is resized.
259 *
260 * @param mode One of 5 legal values:
261 * AUTO_RESIZE_OFF,
262 * AUTO_RESIZE_NEXT_COLUMN,
263 * AUTO_RESIZE_SUBSEQUENT_COLUMNS,
264 * AUTO_RESIZE_LAST_COLUMN,
265 * AUTO_RESIZE_ALL_COLUMNS
266 *
267 * @see #getAutoResizeMode
268 * @see #doLayout
269 * @beaninfo
270 * bound: true
271 * description: Whether the columns should adjust themselves automatically.
272 * enum: AUTO_RESIZE_OFF JXTable.AUTO_RESIZE_OFF
273 * AUTO_RESIZE_NEXT_COLUMN JXTable.AUTO_RESIZE_NEXT_COLUMN
274 * AUTO_RESIZE_SUBSEQUENT_COLUMNS JXTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS
275 * AUTO_RESIZE_LAST_COLUMN JXTable.AUTO_RESIZE_LAST_COLUMN
276 * AUTO_RESIZE_ALL_COLUMNS JXTable.AUTO_RESIZE_ALL_COLUMNS
277 */
278 void setAutoResizeMode(int mode);
279
280 /***
281 * Returns the auto resize mode of the table. The default mode
282 * is AUTO_RESIZE_SUBSEQUENT_COLUMNS.
283 *
284 * @return the autoResizeMode of the table
285 *
286 * @see #setAutoResizeMode
287 * @see #doLayout
288 */
289 int getAutoResizeMode();
290
291 /***
292 * Sets this table's <code>autoCreateColumnsFromModel</code> flag.
293 * This method calls <code>createDefaultColumnsFromModel</code> if
294 * <code>autoCreateColumnsFromModel</code> changes from false to true.
295 *
296 * @param autoCreateColumnsFromModel true if <code>JXTable</code> should automatically create columns
297 * @see #getAutoCreateColumnsFromModel
298 * @see #createDefaultColumnsFromModel
299 * @beaninfo
300 * bound: true
301 * description: Automatically populates the columnModel when a new TableModel is submitted.
302 */
303 void setAutoCreateColumnsFromModel(
304 boolean autoCreateColumnsFromModel);
305
306 /***
307 * Determines whether the table will create default columns from the model.
308 * If true, <code>setModel</code> will clear any existing columns and
309 * create new columns from the new model. Also, if the event in
310 * the <code>tableChanged</code> notification specifies that the
311 * entire table changed, then the columns will be rebuilt.
312 * The default is true.
313 *
314 * @return the autoCreateColumnsFromModel of the table
315 * @see #setAutoCreateColumnsFromModel
316 * @see #createDefaultColumnsFromModel
317 */
318 boolean getAutoCreateColumnsFromModel();
319
320 /***
321 * Creates default columns for the table from
322 * the data model using the <code>getColumnCount</code> method
323 * defined in the <code>TableModel</code> interface.
324 * <p>
325 * Clears any existing columns before creating the
326 * new columns based on information from the model.
327 *
328 * @see #getAutoCreateColumnsFromModel
329 */
330 void createDefaultColumnsFromModel();
331
332 /***
333 * Sets a default cell renderer to be used if no renderer has been set in
334 * a <code>TableColumn</code>. If renderer is <code>null</code>,
335 * removes the default renderer for this column class.
336 *
337 * @param columnClass set the default cell renderer for this columnClass
338 * @param renderer default cell renderer to be used for this
339 * columnClass
340 * @see #getDefaultRenderer
341 * @see #setDefaultEditor
342 */
343 void setDefaultRenderer(Class columnClass,
344 TableCellRenderer renderer);
345
346 /***
347 * Returns the cell renderer to be used when no renderer has been set in
348 * a <code>TableColumn</code>. During the rendering of cells the renderer is fetched from
349 * a <code>Hashtable</code> of entries according to the class of the cells in the column. If
350 * there is no entry for this <code>columnClass</code> the method returns
351 * the entry for the most specific superclass. The <code>JXTable</code> installs entries
352 * for <code>Object</code>, <code>Number</code>, and <code>Boolean</code>, all of which can be modified
353 * or replaced.
354 *
355 * @param columnClass return the default cell renderer
356 * for this columnClass
357 * @return the renderer for this columnClass
358 * @see #setDefaultRenderer
359 * @see #getColumnClass
360 */
361 TableCellRenderer getDefaultRenderer(Class columnClass);
362
363 /***
364 * Sets a default cell editor to be used if no editor has been set in
365 * a <code>TableColumn</code>. If no editing is required in a table, or a
366 * particular column in a table, uses the <code>isCellEditable</code>
367 * method in the <code>TableModel</code> interface to ensure that this
368 * <code>JXTable</code> will not start an editor in these columns.
369 * If editor is <code>null</code>, removes the default editor for this
370 * column class.
371 *
372 * @param columnClass set the default cell editor for this columnClass
373 * @param editor default cell editor to be used for this columnClass
374 * @see TableModel#isCellEditable
375 * @see #getDefaultEditor
376 * @see #setDefaultRenderer
377 */
378 void setDefaultEditor(Class columnClass,
379 TableCellEditor editor);
380
381 /***
382 * Returns the editor to be used when no editor has been set in
383 * a <code>TableColumn</code>. During the editing of cells the editor is fetched from
384 * a <code>Hashtable</code> of entries according to the class of the cells in the column. If
385 * there is no entry for this <code>columnClass</code> the method returns
386 * the entry for the most specific superclass. The <code>JXTable</code> installs entries
387 * for <code>Object</code>, <code>Number</code>, and <code>Boolean</code>, all of which can be modified
388 * or replaced.
389 *
390 * @param columnClass return the default cell editor for this columnClass
391 * @return the default cell editor to be used for this columnClass
392 * @see #setDefaultEditor
393 * @see #getColumnClass
394 */
395 TableCellEditor getDefaultEditor(Class columnClass);
396
397 /***
398 * Sets the <code>dragEnabled</code> property,
399 * which must be <code>true</code> to enable
400 * automatic drag handling (the first part of drag and drop)
401 * on this component.
402 * The <code>transferHandler</code> property needs to be set
403 * to a non-<code>null</code> value for the drag to do
404 * anything. The default value of the <code>dragEnabled</code>
405 * property
406 * is <code>false</code>.
407 *
408 * <p>
409 *
410 * When automatic drag handling is enabled,
411 * most look and feels begin a drag-and-drop operation
412 * whenever the user presses the mouse button over a selection
413 * and then moves the mouse a few pixels.
414 * Setting this property to <code>true</code>
415 * can therefore have a subtle effect on
416 * how selections behave.
417 *
418 * <p>
419 *
420 * Some look and feels might not support automatic drag and drop;
421 * they will ignore this property. You can work around such
422 * look and feels by modifying the component
423 * to directly call the <code>exportAsDrag</code> method of a
424 * <code>TransferHandler</code>.
425 *
426 * @param b the value to set the <code>dragEnabled</code> property to
427 * @exception HeadlessException if
428 * <code>b</code> is <code>true</code> and
429 * <code>GraphicsEnvironment.isHeadless()</code>
430 * returns <code>true</code>
431 * @see java.awt.GraphicsEnvironment#isHeadless
432 * @see #getDragEnabled
433 * @see #setTransferHandler
434 * @see TransferHandler
435 * @since 1.4
436 *
437 * @beaninfo
438 * description: determines whether automatic drag handling is enabled
439 * bound: false
440 */
441 void setDragEnabled(boolean b) throws HeadlessException;
442
443 /***
444 * Gets the value of the <code>dragEnabled</code> property.
445 *
446 * @return the value of the <code>dragEnabled</code> property
447 * @see #setDragEnabled
448 * @since 1.4
449 */
450 boolean getDragEnabled();
451
452 /***
453 * Sets the table's selection mode to allow only single selections, a single
454 * contiguous interval, or multiple intervals.
455 * <P>
456 * <bold>Note:</bold>
457 * <code>JTable</code> provides all the methods for handling
458 * column and row selection. When setting states,
459 * such as <code>setSelectionMode</code>, it not only
460 * updates the mode for the row selection model but also sets similar
461 * values in the selection model of the <code>columnModel</code>.
462 * If you want to have the row and column selection models operating
463 * in different modes, set them both directly.
464 * <p>
465 * Both the row and column selection models for <code>JTable</code>
466 * default to using a <code>DefaultListSelectionModel</code>
467 * so that <code>JTable</code> works the same way as the
468 * <code>JList</code>. See the <code>setSelectionMode</code> method
469 * in <code>JList</code> for details about the modes.
470 *
471 * @see JList#setSelectionMode
472 * @beaninfo
473 * description: The selection mode used by the row and column selection models.
474 * enum: SINGLE_SELECTION ListSelectionModel.SINGLE_SELECTION
475 * SINGLE_INTERVAL_SELECTION ListSelectionModel.SINGLE_INTERVAL_SELECTION
476 * MULTIPLE_INTERVAL_SELECTION ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
477 */
478 void setSelectionMode(int selectionMode);
479
480 /***
481 * Sets whether the rows in this model can be selected.
482 *
483 * @param rowSelectionAllowed true if this model will allow row selection
484 * @see #getRowSelectionAllowed
485 * @beaninfo
486 * bound: true
487 * attribute: visualUpdate true
488 * description: If true, an entire row is selected for each selected cell.
489 */
490 void setRowSelectionAllowed(boolean rowSelectionAllowed);
491
492 /***
493 * Returns true if rows can be selected.
494 *
495 * @return true if rows can be selected, otherwise false
496 * @see #setRowSelectionAllowed
497 */
498 boolean getRowSelectionAllowed();
499
500 /***
501 * Sets whether the columns in this model can be selected.
502 *
503 * @param columnSelectionAllowed true if this model will allow column selection
504 * @see #getColumnSelectionAllowed
505 * @beaninfo
506 * bound: true
507 * attribute: visualUpdate true
508 * description: If true, an entire column is selected for each selected cell.
509 */
510 void setColumnSelectionAllowed(
511 boolean columnSelectionAllowed);
512
513 /***
514 * Returns true if columns can be selected.
515 *
516 * @return true if columns can be selected, otherwise false
517 * @see #setColumnSelectionAllowed
518 */
519 boolean getColumnSelectionAllowed();
520
521 /***
522 * Sets whether this table allows both a column selection and a
523 * row selection to exist simultaneously. When set,
524 * the table treats the intersection of the row and column selection
525 * models as the selected cells. Override <code>isCellSelected</code> to
526 * change this default behavior. This method is equivalent to setting
527 * both the <code>rowSelectionAllowed</code> property and
528 * <code>columnSelectionAllowed</code> property of the
529 * <code>columnModel</code> to the supplied value.
530 *
531 * @param cellSelectionEnabled true if simultaneous row and column
532 * selection is allowed
533 * @see #getCellSelectionEnabled
534 * @see #isCellSelected
535 * @beaninfo
536 * bound: true
537 * attribute: visualUpdate true
538 * description: Select a rectangular region of cells rather than
539 * rows or columns.
540 */
541 void setCellSelectionEnabled(boolean cellSelectionEnabled);
542
543 /***
544 * Returns true if both row and column selection models are enabled.
545 * Equivalent to <code>getRowSelectionAllowed() &&
546 * getColumnSelectionAllowed()</code>.
547 *
548 * @return true if both row and column selection models are enabled
549 *
550 * @see #setCellSelectionEnabled
551 */
552 boolean getCellSelectionEnabled();
553
554 /***
555 * Selects all rows, columns, and cells in the table.
556 */
557 void selectAll();
558
559 /***
560 * Deselects all selected columns and rows.
561 */
562 void clearSelection();
563
564 /***
565 * Selects the rows from <code>index0</code> to <code>index1</code>,
566 * inclusive.
567 *
568 * @exception IllegalArgumentException if <code>index0</code> or
569 * <code>index1</code> lie outside
570 * [0, <code>getRowCount()</code>-1]
571 * @param index0 one end of the interval
572 * @param index1 the other end of the interval
573 */
574 void setRowSelectionInterval(int index0, int index1) throws IllegalArgumentException;
575
576 /***
577 * Selects the columns from <code>index0</code> to <code>index1</code>,
578 * inclusive.
579 *
580 * @exception IllegalArgumentException if <code>index0</code> or
581 * <code>index1</code> lie outside
582 * [0, <code>getColumnCount()</code>-1]
583 * @param index0 one end of the interval
584 * @param index1 the other end of the interval
585 */
586 void setColumnSelectionInterval(int index0, int index1) throws IllegalArgumentException;
587
588 /***
589 * Adds the rows from <code>index0</code> to <code>index1</code>, inclusive, to
590 * the current selection.
591 *
592 * @exception IllegalArgumentException if <code>index0</code> or <code>index1</code>
593 * lie outside [0, <code>getRowCount()</code>-1]
594 * @param index0 one end of the interval
595 * @param index1 the other end of the interval
596 */
597 void addRowSelectionInterval(int index0, int index1) throws IllegalArgumentException;
598
599 /***
600 * Adds the columns from <code>index0</code> to <code>index1</code>,
601 * inclusive, to the current selection.
602 *
603 * @exception IllegalArgumentException if <code>index0</code> or
604 * <code>index1</code> lie outside
605 * [0, <code>getColumnCount()</code>-1]
606 * @param index0 one end of the interval
607 * @param index1 the other end of the interval
608 */
609 void addColumnSelectionInterval(int index0, int index1) throws IllegalArgumentException;
610
611 /***
612 * Deselects the rows from <code>index0</code> to <code>index1</code>, inclusive.
613 *
614 * @exception IllegalArgumentException if <code>index0</code> or
615 * <code>index1</code> lie outside
616 * [0, <code>getRowCount()</code>-1]
617 * @param index0 one end of the interval
618 * @param index1 the other end of the interval
619 */
620 void removeRowSelectionInterval(int index0, int index1) throws IllegalArgumentException;
621
622 /***
623 * Deselects the columns from <code>index0</code> to <code>index1</code>, inclusive.
624 *
625 * @exception IllegalArgumentException if <code>index0</code> or
626 * <code>index1</code> lie outside
627 * [0, <code>getColumnCount()</code>-1]
628 * @param index0 one end of the interval
629 * @param index1 the other end of the interval
630 */
631 void removeColumnSelectionInterval(int index0, int index1) throws IllegalArgumentException;
632
633 /***
634 * Returns the index of the first selected row, -1 if no row is selected.
635 * @return the index of the first selected row
636 */
637 int getSelectedRow();
638
639 /***
640 * Returns the index of the first selected column,
641 * -1 if no column is selected.
642 * @return the index of the first selected column
643 */
644 int getSelectedColumn();
645
646 /***
647 * Returns the indices of all selected rows.
648 *
649 * @return an array of integers containing the indices of all selected rows,
650 * or an empty array if no row is selected
651 * @see #getSelectedRow
652 */
653 int[] getSelectedRows();
654
655 /***
656 * Returns the indices of all selected columns.
657 *
658 * @return an array of integers containing the indices of all selected columns,
659 * or an empty array if no column is selected
660 * @see #getSelectedColumn
661 */
662 int[] getSelectedColumns();
663
664 /***
665 * Returns the number of selected rows.
666 *
667 * @return the number of selected rows, 0 if no rows are selected
668 */
669 int getSelectedRowCount();
670
671 /***
672 * Returns the number of selected columns.
673 *
674 * @return the number of selected columns, 0 if no columns are selected
675 */
676 int getSelectedColumnCount();
677
678 /***
679 * Returns true if the row at the specified index is selected.
680 *
681 * @param row the row being queried
682 * @return true if the row at index <code>row</code> is selected, where 0 is the
683 * first row
684 * @exception IllegalArgumentException if <code>row</code> is not in the
685 * valid range
686 */
687 boolean isRowSelected(int row) throws IllegalArgumentException;
688
689 /***
690 * Returns true if the column at the specified index is selected.
691 *
692 * @param column the column in the column model
693 * @return true if the column at index <code>column</code> is selected, where
694 * 0 is the first column
695 * @exception IllegalArgumentException if <code>column</code> is not in the
696 * valid range
697 */
698 boolean isColumnSelected(int column) throws IllegalArgumentException;
699
700 /***
701 * Returns true if the cell at the specified position is selected.
702 * @param row the row being queried
703 * @param column the column being queried
704 *
705 * @return true if the cell at index <code>(row, column)</code> is selected,
706 * where the first row and first column are at index 0
707 * @exception IllegalArgumentException if <code>row</code> or <code>column</code>
708 * are not in the valid range
709 */
710 boolean isCellSelected(int row, int column) throws IllegalArgumentException;
711
712 /***
713 * Updates the selection models of the table, depending on the state of the
714 * two flags: <code>toggle</code> and <code>extend</code>. All changes
715 * to the selection that are the result of keyboard or mouse events received
716 * by the UI are channeled through this method so that the behavior may be
717 * overridden by a subclass.
718 * <p>
719 * This implementation uses the following conventions:
720 * <ul>
721 * <li> <code>toggle</code>: <em>false</em>, <code>extend</code>: <em>false</em>.
722 * Clear the previous selection and ensure the new cell is selected.
723 * <li> <code>toggle</code>: <em>false</em>, <code>extend</code>: <em>true</em>.
724 * Extend the previous selection to include the specified cell.
725 * <li> <code>toggle</code>: <em>true</em>, <code>extend</code>: <em>false</em>.
726 * If the specified cell is selected, deselect it. If it is not selected, select it.
727 * <li> <code>toggle</code>: <em>true</em>, <code>extend</code>: <em>true</em>.
728 * Leave the selection state as it is, but move the anchor index to the specified location.
729 * </ul>
730 * @param rowIndex affects the selection at <code>row</code>
731 * @param columnIndex affects the selection at <code>column</code>
732 * @param toggle see description above
733 * @param extend if true, extend the current selection
734 *
735 */
736 void changeSelection(int rowIndex, int columnIndex,
737 boolean toggle, boolean extend);
738
739 /***
740 * Returns the foreground color for selected cells.
741 *
742 * @return the <code>Color</code> object for the foreground property
743 * @see #setSelectionForeground
744 * @see #setSelectionBackground
745 */
746 Color getSelectionForeground();
747
748 /***
749 * Sets the foreground color for selected cells. Cell renderers
750 * can use this color to render text and graphics for selected
751 * cells.
752 * <p>
753 * The default value of this property is defined by the look
754 * and feel implementation.
755 * <p>
756 * This is a <a href="http://java.sun.com/docs/books/tutorial/javabeans/whatis/beanDefinition.html">JavaBeans</a>
757 * bound property.
758 *
759 * @param selectionForeground the <code>Color</code> to use in the foreground
760 * for selected list items
761 * @see #getSelectionForeground
762 * @see #setSelectionBackground
763 * @see #setForeground
764 * @see #setBackground
765 * @see #setFont
766 * @beaninfo
767 * bound: true
768 * description: A default foreground color for selected cells.
769 */
770 void setSelectionForeground(Color selectionForeground);
771
772 /***
773 * Returns the background color for selected cells.
774 *
775 * @return the <code>Color</code> used for the background of selected list items
776 * @see #setSelectionBackground
777 * @see #setSelectionForeground
778 */
779 Color getSelectionBackground();
780
781 /***
782 * Sets the background color for selected cells. Cell renderers
783 * can use this color to the fill selected cells.
784 * <p>
785 * The default value of this property is defined by the look
786 * and feel implementation.
787 * <p>
788 * This is a <a href="http://java.sun.com/docs/books/tutorial/javabeans/whatis/beanDefinition.html">JavaBeans</a>
789 * bound property.
790 *
791 * @param selectionBackground the <code>Color</code> to use for the background
792 * of selected cells
793 * @see #getSelectionBackground
794 * @see #setSelectionForeground
795 * @see #setForeground
796 * @see #setBackground
797 * @see #setFont
798 * @beaninfo
799 * bound: true
800 * description: A default background color for selected cells.
801 */
802 void setSelectionBackground(Color selectionBackground);
803
804 /***
805 * Returns the <code>TableColumn</code> object for the column in the table
806 * whose identifier is equal to <code>identifier</code>, when compared using
807 * <code>equals</code>.
808 *
809 * @return the <code>TableColumn</code> object that matches the identifier
810 * @exception IllegalArgumentException if <code>identifier</code>
811 * is <code>null</code> or no <code>TableColumn</code> has this identifier.
812 *
813 * @param identifier the identifier object
814 */
815 TableColumn getColumn(Object identifier) throws IllegalArgumentException;
816
817 /***
818 * Maps the index of the column in the view at
819 * <code>viewColumnIndex</code> to the index of the column
820 * in the table model. Returns the index of the corresponding
821 * column in the model. If <code>viewColumnIndex</code>
822 * is less than zero, returns <code>viewColumnIndex</code>.
823 *
824 * @param viewColumnIndex the index of the column in the view
825 * @return the index of the corresponding column in the model
826 *
827 * @see #convertColumnIndexToView
828 */
829 int convertColumnIndexToModel(int viewColumnIndex);
830
831 /***
832 * Maps the index of the column in the table model at
833 * <code>modelColumnIndex</code> to the index of the column
834 * in the view. Returns the index of the
835 * corresponding column in the view; returns -1 if this column is not
836 * being displayed. If <code>modelColumnIndex</code> is less than zero,
837 * returns <code>modelColumnIndex</code>.
838 *
839 * @param modelColumnIndex the index of the column in the model
840 * @return the index of the corresponding column in the view
841 *
842 * @see #convertColumnIndexToModel
843 */
844 int convertColumnIndexToView(int modelColumnIndex);
845
846 /***
847 * Returns the number of rows in this table's model.
848 * @return the number of rows in this table's model
849 *
850 * @see #getColumnCount
851 */
852 int getRowCount();
853
854 /***
855 * Returns the number of columns in the column model. Note that this may
856 * be different from the number of columns in the table model.
857 *
858 * @return the number of columns in the table
859 * @see #getRowCount
860 * @see #removeColumn
861 */
862 int getColumnCount();
863
864 /***
865 * Returns the name of the column appearing in the view at
866 * column position <code>column</code>.
867 *
868 * @param column the column in the view being queried
869 * @return the name of the column at position <code>column</code>
870 in the view where the first column is column 0
871 */
872 String getColumnName(int column);
873
874 /***
875 * Returns the type of the column appearing in the view at
876 * column position <code>column</code>.
877 *
878 * @param column the column in the view being queried
879 * @return the type of the column at position <code>column</code>
880 * in the view where the first column is column 0
881 */
882 Class getColumnClass(int column);
883
884 /***
885 * Returns the cell value at <code>row</code> and <code>column</code>.
886 * <p>
887 * <b>Note</b>: The column is specified in the table view's display
888 * order, and not in the <code>TableModel</code>'s column
889 * order. This is an important distinction because as the
890 * user rearranges the columns in the table,
891 * the column at a given index in the view will change.
892 * Meanwhile the user's actions never affect the model's
893 * column ordering.
894 *
895 * @param row the row whose value is to be queried
896 * @param column the column whose value is to be queried
897 * @return the Object at the specified cell
898 */
899 Object getValueAt(int row, int column);
900
901 /***
902 * Sets the value for the cell in the table model at <code>row</code>
903 * and <code>column</code>.
904 * <p>
905 * <b>Note</b>: The column is specified in the table view's display
906 * order, and not in the <code>TableModel</code>'s column
907 * order. This is an important distinction because as the
908 * user rearranges the columns in the table,
909 * the column at a given index in the view will change.
910 * Meanwhile the user's actions never affect the model's
911 * column ordering.
912 *
913 * <code>aValue</code> is the new value.
914 *
915 * @param aValue the new value
916 * @param row the row of the cell to be changed
917 * @param column the column of the cell to be changed
918 * @see #getValueAt
919 */
920 void setValueAt(Object aValue, int row, int column);
921
922 /***
923 * Returns true if the cell at <code>row</code> and <code>column</code>
924 * is editable. Otherwise, invoking <code>setValueAt</code> on the cell
925 * will have no effect.
926 * <p>
927 * <b>Note</b>: The column is specified in the table view's display
928 * order, and not in the <code>TableModel</code>'s column
929 * order. This is an important distinction because as the
930 * user rearranges the columns in the table,
931 * the column at a given index in the view will change.
932 * Meanwhile the user's actions never affect the model's
933 * column ordering.
934 *
935 *
936 * @param row the row whose value is to be queried
937 * @param column the column whose value is to be queried
938 * @return true if the cell is editable
939 * @see #setValueAt
940 */
941 boolean isCellEditable(int row, int column);
942
943 /***
944 * Appends <code>aColumn</code> to the end of the array of columns held by
945 * this <code>JTable</code>'s column model.
946 * If the column name of <code>aColumn</code> is <code>null</code>,
947 * sets the column name of <code>aColumn</code> to the name
948 * returned by <code>getModel().getColumnName()</code>.
949 * <p>
950 * To add a column to this <code>JTable</code> to display the
951 * <code>modelColumn</code>'th column of data in the model with a
952 * given <code>width</code>, <code>cellRenderer</code>,
953 * and <code>cellEditor</code> you can use:
954 * <pre>
955 *
956 * addColumn(new TableColumn(modelColumn, width, cellRenderer, cellEditor));
957 *
958 * </pre>
959 * [Any of the <code>TableColumn</code> constructors can be used
960 * instead of this one.]
961 * The model column number is stored inside the <code>TableColumn</code>
962 * and is used during rendering and editing to locate the appropriates
963 * data values in the model. The model column number does not change
964 * when columns are reordered in the view.
965 *
966 * @param aColumn the <code>TableColumn</code> to be added
967 * @see #removeColumn
968 */
969 void addColumn(TableColumn aColumn);
970
971 /***
972 * Removes <code>aColumn</code> from this <code>JXTable</code>'s
973 * array of columns. Note: this method does not remove the column
974 * of data from the model; it just removes the <code>TableColumn</code>
975 * that was responsible for displaying it.
976 *
977 * @param aColumn the <code>TableColumn</code> to be removed
978 * @see #addColumn
979 */
980 void removeColumn(TableColumn aColumn);
981
982 /***
983 * Moves the column <code>column</code> to the position currently
984 * occupied by the column <code>targetColumn</code> in the view.
985 * The old column at <code>targetColumn</code> is
986 * shifted left or right to make room.
987 *
988 * @param column the index of column to be moved
989 * @param targetColumn the new index of the column
990 */
991 void moveColumn(int column, int targetColumn);
992
993 /***
994 * Returns the index of the column that <code>point</code> lies in,
995 * or -1 if the result is not in the range
996 * [0, <code>getColumnCount()</code>-1].
997 *
998 * @param point the location of interest
999 * @return the index of the column that <code>point</code> lies in,
1000 * or -1 if the result is not in the range
1001 * [0, <code>getColumnCount()</code>-1]
1002 * @see #rowAtPoint
1003 */
1004 int columnAtPoint(Point point);
1005
1006 /***
1007 * Returns the index of the row that <code>point</code> lies in,
1008 * or -1 if the result is not in the range
1009 * [0, <code>getRowCount()</code>-1].
1010 *
1011 * @param point the location of interest
1012 * @return the index of the row that <code>point</code> lies in,
1013 * or -1 if the result is not in the range
1014 * [0, <code>getRowCount()</code>-1]
1015 * @see #columnAtPoint
1016 */
1017 int rowAtPoint(Point point);
1018
1019 /***
1020 * Returns a rectangle for the cell that lies at the intersection of
1021 * <code>row</code> and <code>column</code>.
1022 * If <code>includeSpacing</code> is true then the value returned
1023 * has the full height and width of the row and column
1024 * specified. If it is false, the returned rectangle is inset by the
1025 * intercell spacing to return the true bounds of the rendering or
1026 * editing component as it will be set during rendering.
1027 * <p>
1028 * If the column index is valid but the row index is less
1029 * than zero the method returns a rectangle with the
1030 * <code>y</code> and <code>height</code> values set appropriately
1031 * and the <code>x</code> and <code>width</code> values both set
1032 * to zero. In general, when either the row or column indices indicate a
1033 * cell outside the appropriate range, the method returns a rectangle
1034 * depicting the closest edge of the closest cell that is within
1035 * the table's range. When both row and column indices are out
1036 * of range the returned rectangle covers the closest
1037 * point of the closest cell.
1038 * <p>
1039 * In all cases, calculations that use this method to calculate
1040 * results along one axis will not fail because of anomalies in
1041 * calculations along the other axis. When the cell is not valid
1042 * the <code>includeSpacing</code> parameter is ignored.
1043 *
1044 * @param row the row index where the desired cell
1045 * is located
1046 * @param column the column index where the desired cell
1047 * is located in the display; this is not
1048 * necessarily the same as the column index
1049 * in the data model for the table; the
1050 * {@link #convertColumnIndexToView(int)}
1051 * method may be used to convert a data
1052 * model column index to a display
1053 * column index
1054 * @param includeSpacing if false, return the true cell bounds -
1055 * computed by subtracting the intercell
1056 * spacing from the height and widths of
1057 * the column and row models
1058 *
1059 * @return the rectangle containing the cell at location
1060 * <code>row</code>,<code>column</code>
1061 */
1062 Rectangle getCellRect(int row, int column,
1063 boolean includeSpacing);
1064
1065 /***
1066 * Causes this table to lay out its rows and columns. Overridden so
1067 * that columns can be resized to accomodate a change in the size of
1068 * a containing parent.
1069 * Resizes one or more of the columns in the table
1070 * so that the total width of all of this <code>JXTable</code>'s
1071 * columns is equal to the width of the table.
1072 * <p>
1073 * Before the layout begins the method gets the
1074 * <code>resizingColumn</code> of the <code>tableHeader</code>.
1075 * When the method is called as a result of the resizing of an enclosing window,
1076 * the <code>resizingColumn</code> is <code>null</code>. This means that resizing
1077 * has taken place "outside" the <code>JXTable</code> and the change -
1078 * or "delta" - should be distributed to all of the columns regardless
1079 * of this <code>JXTable</code>'s automatic resize mode.
1080 * <p>
1081 * If the <code>resizingColumn</code> is not <code>null</code>, it is one of
1082 * the columns in the table that has changed size rather than
1083 * the table itself. In this case the auto-resize modes govern
1084 * the way the extra (or deficit) space is distributed
1085 * amongst the available columns.
1086 * <p>
1087 * The modes are:
1088 * <ul>
1089 * <li> AUTO_RESIZE_OFF: Don't automatically adjust the column's
1090 * widths at all. Use a horizontal scrollbar to accomodate the
1091 * columns when their sum exceeds the width of the
1092 * <code>Viewport</code>. If the <code>JXTable</code> is not
1093 * enclosed in a <code>JScrollPane</code> this may
1094 * leave parts of the table invisible.
1095 * <li> AUTO_RESIZE_NEXT_COLUMN: Use just the column after the
1096 * resizing column. This results in the "boundary" or divider
1097 * between adjacent cells being independently adjustable.
1098 * <li> AUTO_RESIZE_SUBSEQUENT_COLUMNS: Use all columns after the
1099 * one being adjusted to absorb the changes. This is the
1100 * default behavior.
1101 * <li> AUTO_RESIZE_LAST_COLUMN: Automatically adjust the
1102 * size of the last column only. If the bounds of the last column
1103 * prevent the desired size from being allocated, set the
1104 * width of the last column to the appropriate limit and make
1105 * no further adjustments.
1106 * <li> AUTO_RESIZE_ALL_COLUMNS: Spread the delta amongst all the columns
1107 * in the <code>JXTable</code>, including the one that is being
1108 * adjusted.
1109 * </ul>
1110 * <p>
1111 * <bold>Note:</bold> When a <code>JXTable</code> makes adjustments
1112 * to the widths of the columns it respects their minimum and
1113 * maximum values absolutely. It is therefore possible that,
1114 * even after this method is called, the total width of the columns
1115 * is still not equal to the width of the table. When this happens
1116 * the <code>JXTable</code> does not put itself
1117 * in AUTO_RESIZE_OFF mode to bring up a scroll bar, or break other
1118 * commitments of its current auto-resize mode -- instead it
1119 * allows its bounds to be set larger (or smaller) than the total of the
1120 * column minimum or maximum, meaning, either that there
1121 * will not be enough room to display all of the columns, or that the
1122 * columns will not fill the <code>JXTable</code>'s bounds.
1123 * These respectively, result in the clipping of some columns
1124 * or an area being painted in the <code>JXTable</code>'s
1125 * background color during painting.
1126 * <p>
1127 * The mechanism for distributing the delta amongst the available
1128 * columns is provided in a private method in the <code>JXTable</code>
1129 * class:
1130 * <pre>
1131 * adjustSizes(long targetSize, final Resizable3 r, boolean inverse)
1132 * </pre>
1133 * an explanation of which is provided in the following section.
1134 * <code>Resizable3</code> is a private
1135 * interface that allows any data structure containing a collection
1136 * of elements with a size, preferred size, maximum size and minimum size
1137 * to have its elements manipulated by the algorithm.
1138 * <p>
1139 * <H3> Distributing the delta </H3>
1140 * <p>
1141 * <H4> Overview </H4>
1142 * <P>
1143 * Call "DELTA" the difference between the target size and the
1144 * sum of the preferred sizes of the elements in r. The individual
1145 * sizes are calculated by taking the original preferred
1146 * sizes and adding a share of the DELTA - that share being based on
1147 * how far each preferred size is from its limiting bound (minimum or
1148 * maximum).
1149 * <p>
1150 * <H4>Definition</H4>
1151 * <P>
1152 * Call the individual constraints min[i], max[i], and pref[i].
1153 * <p>
1154 * Call their respective sums: MIN, MAX, and PREF.
1155 * <p>
1156 * Each new size will be calculated using:
1157 * <p>
1158 * <pre>
1159 * size[i] = pref[i] + delta[i]
1160 * </pre>
1161 * where each individual delta[i] is calculated according to:
1162 * <p>
1163 * If (DELTA < 0) we are in shrink mode where:
1164 * <p>
1165 * <PRE>
1166 * DELTA
1167 * delta[i] = ------------ * (pref[i] - min[i])
1168 * (PREF - MIN)
1169 * </PRE>
1170 * If (DELTA > 0) we are in expand mode where:
1171 * <p>
1172 * <PRE>
1173 * DELTA
1174 * delta[i] = ------------ * (max[i] - pref[i])
1175 * (MAX - PREF)
1176 * </PRE>
1177 * <P>
1178 * The overall effect is that the total size moves that same percentage,
1179 * k, towards the total minimum or maximum and that percentage guarantees
1180 * accomodation of the required space, DELTA.
1181 *
1182 * <H4>Details</H4>
1183 * <P>
1184 * Naive evaluation of the formulae presented here would be subject to
1185 * the aggregated rounding errors caused by doing this operation in finite
1186 * precision (using ints). To deal with this, the multiplying factor above,
1187 * is constantly recalculated and this takes account of the rounding
1188 * errors in the previous iterations. The result is an algorithm that
1189 * produces a set of integers whose values exactly sum to the supplied
1190 * <code>targetSize</code>, and does so by spreading the rounding
1191 * errors evenly over the given elements.
1192 *
1193 * <H4>When the MAX and MIN bounds are hit</H4>
1194 * <P>
1195 * When <code>targetSize</code> is outside the [MIN, MAX] range,
1196 * the algorithm sets all sizes to their appropriate limiting value
1197 * (maximum or minimum).
1198 *
1199 */
1200 void doLayout();
1201
1202 /***
1203 * Sizes the table columns to fit the available space.
1204 * @deprecated As of Swing version 1.0.3,
1205 * replaced by <code>doLayout()</code>.
1206 * @see #doLayout
1207 */
1208 void sizeColumnsToFit(boolean lastColumnOnly);
1209
1210 /***
1211 * Obsolete as of Java 2 platform v1.4. Please use the
1212 * <code>doLayout()</code> method instead.
1213 * @param resizingColumn the column whose resizing made this adjustment
1214 * necessary or -1 if there is no such column
1215 * @see #doLayout
1216 */
1217 void sizeColumnsToFit(int resizingColumn);
1218
1219 /***
1220 * Overrides <code>JComponent</code>'s <code>getToolTipText</code>
1221 * method in order to allow the renderer's tips to be used
1222 * if it has text set.
1223 * <p>
1224 * <bold>Note:</bold> For <code>JXTable</code> to properly display
1225 * tooltips of its renderers
1226 * <code>JXTable</code> must be a registered component with the
1227 * <code>ToolTipManager</code>.
1228 * This is done automatically in <code>initializeLocalVars</code>,
1229 * but if at a later point <code>JXTable</code> is told
1230 * <code>setToolTipText(null)</code> it will unregister the table
1231 * component, and no tips from renderers will display anymore.
1232 *
1233 * @see JComponent#getToolTipText
1234 */
1235 String getToolTipText(MouseEvent event);
1236
1237 /***
1238 * Sets whether editors in this JTable get the keyboard focus
1239 * when an editor is activated as a result of the JTable
1240 * forwarding keyboard events for a cell.
1241 * By default, this property is false, and the JTable
1242 * retains the focus unless the cell is clicked.
1243 *
1244 * @param surrendersFocusOnKeystroke true if the editor should get the focus
1245 * when keystrokes cause the editor to be
1246 * activated
1247 *
1248 * @see #getSurrendersFocusOnKeystroke
1249 */
1250 void setSurrendersFocusOnKeystroke(boolean surrendersFocusOnKeystroke);
1251
1252 /***
1253 * Returns true if the editor should get the focus
1254 * when keystrokes cause the editor to be activated.
1255 *
1256 * @return true if the editor should get the focus
1257 * when keystrokes cause the editor to be
1258 * activated
1259 *
1260 * @see #setSurrendersFocusOnKeystroke
1261 */
1262 boolean getSurrendersFocusOnKeystroke();
1263
1264 /***
1265 * Programmatically starts editing the cell at <code>row</code> and
1266 * <code>column</code>, if the cell is editable. Note that this is
1267 * a convenience method for <code>editCellAt(int, int, null)</code>.
1268 *
1269 * @param row the row to be edited
1270 * @param column the column to be edited
1271 * @exception IllegalArgumentException if <code>row</code> or
1272 * <code>column</code>
1273 * is not in the valid range
1274 * @return false if for any reason the cell cannot be edited
1275 */
1276 boolean editCellAt(int row, int column) throws IllegalArgumentException;
1277
1278 /***
1279 * Programmatically starts editing the cell at <code>row</code> and
1280 * <code>column</code>, if the cell is editable.
1281 * To prevent the <code>JXTable</code> from editing a particular table,
1282 * column or cell value, return false from the <code>isCellEditable</code>
1283 * method in the <code>TableModel</code> interface.
1284 *
1285 * @param row the row to be edited
1286 * @param column the column to be edited
1287 * @param e event to pass into <code>shouldSelectCell</code>;
1288 * note that as of Java 2 platform v1.2, the call to
1289 * <code>shouldSelectCell</code> is no longer made
1290 * @exception IllegalArgumentException if <code>row</code> or
1291 * <code>column</code>
1292 * is not in the valid range
1293 * @return false if for any reason the cell cannot be edited
1294 */
1295 boolean editCellAt(int row, int column, EventObject e) throws IllegalArgumentException;
1296
1297 /***
1298 * Returns true if a cell is being edited.
1299 *
1300 * @return true if the table is editing a cell
1301 * @see #editingColumn
1302 * @see #editingRow
1303 */
1304 boolean isEditing();
1305
1306 /***
1307 * Returns the component that is handling the editing session.
1308 * If nothing is being edited, returns null.
1309 *
1310 * @return Component handling editing session
1311 */
1312 Component getEditorComponent();
1313
1314 /***
1315 * Returns the index of the column that contains the cell currently
1316 * being edited. If nothing is being edited, returns -1.
1317 *
1318 * @return the index of the column that contains the cell currently
1319 * being edited; returns -1 if nothing being edited
1320 * @see #editingRow
1321 */
1322 int getEditingColumn();
1323
1324 /***
1325 * Returns the index of the row that contains the cell currently
1326 * being edited. If nothing is being edited, returns -1.
1327 *
1328 * @return the index of the row that contains the cell currently
1329 * being edited; returns -1 if nothing being edited
1330 * @see #editingColumn
1331 */
1332 int getEditingRow();
1333
1334 /***
1335 * Returns the L&F object that renders this component.
1336 *
1337 * @return the <code>TableUI</code> object that renders this component
1338 */
1339 TableUI getUI();
1340
1341 /***
1342 * Sets the L&F object that renders this component and repaints.
1343 *
1344 * @param ui the TableUI L&F object
1345 * @see UIDefaults#getUI
1346 * @beaninfo
1347 * bound: true
1348 * hidden: true
1349 * attribute: visualUpdate true
1350 * description: The UI object that implements the Component's LookAndFeel.
1351 */
1352 void setUI(TableUI ui);
1353
1354 /***
1355 * Notification from the <code>UIManager</code> that the L&F has changed.
1356 * Replaces the current UI object with the latest version from the
1357 * <code>UIManager</code>.
1358 *
1359 * @see JComponent#updateUI
1360 */
1361 void updateUI();
1362
1363 /***
1364 * Returns the suffix used to construct the name of the L&F class used to
1365 * render this component.
1366 *
1367 * @return the string "TableUI"
1368 * @see JComponent#getUIClassID
1369 * @see UIDefaults#getUI
1370 */
1371 String getUIClassID();
1372
1373 /***
1374 * Sets the data model for this table to <code>newModel</code> and registers
1375 * with it for listener notifications from the new data model.
1376 *
1377 * @param dataModel the new data source for this table
1378 * @exception IllegalArgumentException if <code>newModel</code> is <code>null</code>
1379 * @see #getModel
1380 * @beaninfo
1381 * bound: true
1382 * description: The model that is the source of the data for this view.
1383 */
1384 void setModel(TableModel dataModel) throws IllegalArgumentException;
1385
1386 /***
1387 * Returns the <code>TableModel</code> that provides the data displayed by this
1388 * <code>JXTable</code>.
1389 *
1390 * @return the <code>TableModel</code> that provides the data displayed by this <code>JXTable</code>
1391 * @see #setModel
1392 */
1393 TableModel getModel();
1394
1395 /***
1396 * Sets the column model for this table to <code>newModel</code> and registers
1397 * for listener notifications from the new column model. Also sets
1398 * the column model of the <code>JXTableHeader</code> to <code>columnModel</code>.
1399 *
1400 * @param columnModel the new data source for this table
1401 * @exception IllegalArgumentException if <code>columnModel</code> is <code>null</code>
1402 * @see #getColumnModel
1403 * @beaninfo
1404 * bound: true
1405 * description: The object governing the way columns appear in the view.
1406 */
1407 void setColumnModel(TableColumnModel columnModel) throws IllegalArgumentException;
1408
1409 /***
1410 * Returns the <code>TableColumnModel</code> that contains all column information
1411 * of this table.
1412 *
1413 * @return the object that provides the column state of the table
1414 * @see #setColumnModel
1415 */
1416 TableColumnModel getColumnModel();
1417
1418 /***
1419 * Sets the row selection model for this table to <code>newModel</code>
1420 * and registers for listener notifications from the new selection model.
1421 *
1422 * @param newModel the new selection model
1423 * @exception IllegalArgumentException if <code>newModel</code> is <code>null</code>
1424 * @see #getSelectionModel
1425 * @beaninfo
1426 * bound: true
1427 * description: The selection model for rows.
1428 */
1429 void setSelectionModel(ListSelectionModel newModel) throws IllegalArgumentException;
1430
1431 /***
1432 * Returns the <code>ListSelectionModel</code> that is used to maintain row
1433 * selection state.
1434 *
1435 * @return the object that provides row selection state, <code>null</code>
1436 * if row selection is not allowed
1437 * @see #setSelectionModel
1438 */
1439 ListSelectionModel getSelectionModel();
1440
1441 /***
1442 * Invoked when this table's <code>TableModel</code> generates
1443 * a <code>TableModelEvent</code>.
1444 * The <code>TableModelEvent</code> should be constructed in the
1445 * coordinate system of the model; the appropriate mapping to the
1446 * view coordinate system is performed by this <code>JTable</code>
1447 * when it receives the event.
1448 * <p>
1449 * Application code will not use these methods explicitly, they
1450 * are used internally by <code>JTable</code>.
1451 * <p>
1452 * Note that as of 1.3, this method clears the selection, if any.
1453 * @param e the TableModelEvent encapsulating the insertion
1454 */
1455 void tableChanged(TableModelEvent e);
1456
1457 /***
1458 * Invoked when a column is added to the table column model.
1459 * <p>
1460 * Application code will not use these methods explicitly, they
1461 * are used internally by JTable.
1462 *
1463 * @param e the event received
1464 * @see TableColumnModelListener
1465 */
1466 void columnAdded(TableColumnModelEvent e);
1467
1468 /***
1469 * Invoked when a column is removed from the table column model.
1470 * <p>
1471 * Application code will not use these methods explicitly, they
1472 * are used internally by JXTable.
1473 *
1474 * @see TableColumnModelListener
1475 */
1476 void columnRemoved(TableColumnModelEvent e);
1477
1478 /***
1479 * Invoked when a column is repositioned. If a cell is being
1480 * edited, then editing is stopped and the cell is redrawn.
1481 * <p>
1482 * Application code will not use these methods explicitly, they
1483 * are used internally by JXTable.
1484 *
1485 * @param e the event received
1486 * @see TableColumnModelListener
1487 */
1488 void columnMoved(TableColumnModelEvent e);
1489
1490 /***
1491 * Invoked when a column is moved due to a margin change.
1492 * If a cell is being edited, then editing is stopped and the cell
1493 * is redrawn.
1494 * <p>
1495 * Application code will not use these methods explicitly, they
1496 * are used internally by JXTable.
1497 *
1498 * @param e the event received
1499 * @see TableColumnModelListener
1500 */
1501 void columnMarginChanged(ChangeEvent e);
1502
1503 /***
1504 * Invoked when the selection model of the <code>TableColumnModel</code>
1505 * is changed.
1506 * <p>
1507 * Application code will not use these methods explicitly, they
1508 * are used internally by JXTable.
1509 *
1510 * @param e the event received
1511 * @see TableColumnModelListener
1512 */
1513 void columnSelectionChanged(ListSelectionEvent e);
1514
1515 /***
1516 * Invoked when the row selection changes -- repaints to show the new
1517 * selection.
1518 * <p>
1519 * Application code will not use these methods explicitly, they
1520 * are used internally by JTable.
1521 *
1522 * @param e the event received
1523 * @see ListSelectionListener
1524 */
1525 void valueChanged(ListSelectionEvent e);
1526
1527 /***
1528 * Invoked when editing is finished. The changes are saved and the
1529 * editor is discarded.
1530 * <p>
1531 * Application code will not use these methods explicitly, they
1532 * are used internally by JTable.
1533 *
1534 * @param e the event received
1535 * @see CellEditorListener
1536 */
1537 void editingStopped(ChangeEvent e);
1538
1539 /***
1540 * Invoked when editing is canceled. The editor object is discarded
1541 * and the cell is rendered once again.
1542 * <p>
1543 * Application code will not use these methods explicitly, they
1544 * are used internally by JXTable.
1545 *
1546 * @param e the event received
1547 * @see CellEditorListener
1548 */
1549 void editingCanceled(ChangeEvent e);
1550
1551 /***
1552 * Sets the preferred size of the viewport for this table.
1553 *
1554 * @param size a <code>Dimension</code> object specifying the <code>preferredSize</code> of a
1555 * <code>JViewport</code> whose view is this table
1556 * @see Scrollable#getPreferredScrollableViewportSize
1557 * @beaninfo
1558 * description: The preferred size of the viewport.
1559 */
1560 void setPreferredScrollableViewportSize(Dimension size);
1561
1562 /***
1563 * Returns the preferred size of the viewport for this table.
1564 *
1565 * @return a <code>Dimension</code> object containing the <code>preferredSize</code> of the <code>JViewport</code>
1566 * which displays this table
1567 * @see Scrollable#getPreferredScrollableViewportSize
1568 */
1569 Dimension getPreferredScrollableViewportSize();
1570
1571 /***
1572 * Returns the scroll increment (in pixels) that completely exposes one new
1573 * row or column (depending on the orientation).
1574 * <p>
1575 * This method is called each time the user requests a unit scroll.
1576 *
1577 * @param visibleRect the view area visible within the viewport
1578 * @param orientation either <code>SwingConstants.VERTICAL</code>
1579 * or <code>SwingConstants.HORIZONTAL</code>
1580 * @param direction less than zero to scroll up/left,
1581 * greater than zero for down/right
1582 * @return the "unit" increment for scrolling in the specified direction
1583 * @see Scrollable#getScrollableUnitIncrement
1584 */
1585 int getScrollableUnitIncrement(Rectangle visibleRect,
1586 int orientation, int direction);
1587
1588 /***
1589 * Returns <code>visibleRect.height</code> or
1590 * <code>visibleRect.width</code>,
1591 * depending on this table's orientation. Note that as of Swing 1.1.1
1592 * (Java 2 v 1.2.2) the value
1593 * returned will ensure that the viewport is cleanly aligned on
1594 * a row boundary.
1595 *
1596 * @param visibleRect the visible rect
1597 * @param orientation the orientation
1598 * @param direction the direction
1599 * @return <code>visibleRect.height</code> or
1600 * <code>visibleRect.width</code>
1601 * per the orientation
1602 * @see Scrollable#getScrollableBlockIncrement
1603 */
1604 int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction);
1605
1606 /***
1607 * Returns false if <code>autoResizeMode</code> is set to
1608 * <code>AUTO_RESIZE_OFF</code>, which indicates that the
1609 * width of the viewport does not determine the width
1610 * of the table. Otherwise returns true.
1611 *
1612 * @return false if <code>autoResizeMode</code> is set
1613 * to <code>AUTO_RESIZE_OFF</code>, otherwise returns true
1614 * @see Scrollable#getScrollableTracksViewportWidth
1615 */
1616 boolean getScrollableTracksViewportWidth();
1617
1618 /***
1619 * Returns false to indicate that the height of the viewport does not
1620 * determine the height of the table.
1621 *
1622 * @return false
1623 * @see Scrollable#getScrollableTracksViewportHeight
1624 */
1625 boolean getScrollableTracksViewportHeight();
1626
1627 /***
1628 * Returns the cell editor.
1629 *
1630 * @return the <code>TableCellEditor</code> that does the editing
1631 * @see #cellEditor
1632 */
1633 TableCellEditor getCellEditor();
1634
1635 /***
1636 * Sets the <code>cellEditor</code> variable.
1637 *
1638 * @param anEditor the TableCellEditor that does the editing
1639 * @see #cellEditor
1640 * @beaninfo
1641 * bound: true
1642 * description: The table's active cell editor, if one exists.
1643 */
1644 void setCellEditor(TableCellEditor anEditor);
1645
1646 /***
1647 * Sets the <code>editingColumn</code> variable.
1648 * @param aColumn the column of the cell to be edited
1649 *
1650 * @see #editingColumn
1651 */
1652 void setEditingColumn(int aColumn);
1653
1654 /***
1655 * Sets the <code>editingRow</code> variable.
1656 * @param aRow the row of the cell to be edited
1657 *
1658 * @see #editingRow
1659 */
1660 void setEditingRow(int aRow);
1661
1662 /***
1663 * Returns an appropriate renderer for the cell specified by this row and
1664 * column. If the <code>TableColumn</code> for this column has a non-null
1665 * renderer, returns that. If not, finds the class of the data in
1666 * this column (using <code>getColumnClass</code>)
1667 * and returns the default renderer for this type of data.
1668 * <p>
1669 * <b>Note:</b>
1670 * Throughout the table package, the internal implementations always
1671 * use this method to provide renderers so that this default behavior
1672 * can be safely overridden by a subclass.
1673 *
1674 * @param row the row of the cell to render, where 0 is the first row
1675 * @param column the column of the cell to render,
1676 * where 0 is the first column
1677 * @return the assigned renderer; if <code>null</code>
1678 * returns the default renderer
1679 * for this type of object
1680 * @see javax.swing.table.DefaultTableCellRenderer
1681 * @see javax.swing.table.TableColumn#setCellRenderer
1682 * @see #setDefaultRenderer
1683 */
1684 TableCellRenderer getCellRenderer(int row, int column);
1685
1686 /***
1687 * Prepares the renderer by querying the data model for the
1688 * value and selection state
1689 * of the cell at <code>row</code>, <code>column</code>.
1690 * Returns the component (may be a <code>Component</code>
1691 * or a <code>JComponent</code>) under the event location.
1692 * <p>
1693 * <b>Note:</b>
1694 * Throughout the table package, the internal implementations always
1695 * use this method to prepare renderers so that this default behavior
1696 * can be safely overridden by a subclass.
1697 *
1698 * @param renderer the <code>TableCellRenderer</code> to prepare
1699 * @param row the row of the cell to render, where 0 is the first row
1700 * @param column the column of the cell to render,
1701 * where 0 is the first column
1702 * @return the <code>Component</code> under the event location
1703 */
1704 Component prepareRenderer(TableCellRenderer renderer,
1705 int row, int column);
1706
1707 /***
1708 * Returns an appropriate editor for the cell specified by
1709 * <code>row</code> and <code>column</code>. If the
1710 * <code>TableColumn</code> for this column has a non-null editor,
1711 * returns that. If not, finds the class of the data in this
1712 * column (using <code>getColumnClass</code>)
1713 * and returns the default editor for this type of data.
1714 * <p>
1715 * <b>Note:</b>
1716 * Throughout the table package, the internal implementations always
1717 * use this method to provide editors so that this default behavior
1718 * can be safely overridden by a subclass.
1719 *
1720 * @param row the row of the cell to edit, where 0 is the first row
1721 * @param column the column of the cell to edit,
1722 * where 0 is the first column
1723 * @return the editor for this cell;
1724 * if <code>null</code> return the default editor for
1725 * this type of cell
1726 * @see DefaultCellEditor
1727 */
1728 TableCellEditor getCellEditor(int row, int column);
1729
1730 /***
1731 * Prepares the editor by querying the data model for the value and
1732 * selection state of the cell at <code>row</code>, <code>column</code>.
1733 * <p>
1734 * <b>Note:</b>
1735 * Throughout the table package, the internal implementations always
1736 * use this method to prepare editors so that this default behavior
1737 * can be safely overridden by a subclass.
1738 *
1739 * @param editor the <code>TableCellEditor</code> to set up
1740 * @param row the row of the cell to edit,
1741 * where 0 is the first row
1742 * @param column the column of the cell to edit,
1743 * where 0 is the first column
1744 * @return the <code>Component</code> being edited
1745 */
1746 Component prepareEditor(TableCellEditor editor, int row,
1747 int column);
1748
1749 /***
1750 * Discards the editor object and frees the real estate it used for
1751 * cell rendering.
1752 */
1753 void removeEditor();
1754
1755 /***
1756 * Gets the AccessibleContext associated with this JTable.
1757 * For tables, the AccessibleContext takes the form of an
1758 * AccessibleJTable.
1759 * A new AccessibleJTable instance is created if necessary.
1760 *
1761 * @return an AccessibleJTable that serves as the
1762 * AccessibleContext of this JTable
1763 */
1764 AccessibleContext getAccessibleContext();
1765 }