1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.devaki.nextobjects.ui.components;
21 import javax.swing.JTable;
22 /***
23 * This class overwrite the 'JTable' component
24 */
25 public class CustomTable extends JTable
26 {
27 /***
28 * Construct a 'CustomTable' object
29 * @param autoResize setAutoResizeMode
30 * @param selectionMode setSelectionMode
31 * @param reorderingAllowed setReorderingAllowed
32 * @param resizingAllowed setResizingAllowed
33 */
34 public CustomTable(
35 final boolean autoResize,
36 final int selectionMode,
37 final boolean reorderingAllowed,
38 final boolean resizingAllowed)
39 {
40
41 if (!autoResize)
42 {
43 this.setAutoResizeMode(CustomTable.AUTO_RESIZE_OFF);
44 }
45
46 this.getSelectionModel().setSelectionMode(selectionMode);
47
48 this.getTableHeader().setReorderingAllowed(reorderingAllowed);
49
50 this.getTableHeader().setResizingAllowed(resizingAllowed);
51 }
52 /***
53 * Set the selected row in the jTable
54 * @param i index of the row
55 */
56 public final void setSelectedRow(final int i)
57 {
58 this.getSelectionModel().removeSelectionInterval(
59 0,
60 this.getRowCount() - 1);
61 this.getSelectionModel().addSelectionInterval(i, i);
62 }
63 }