42 |
import javax.swing.table.TableModel; |
import javax.swing.table.TableModel; |
43 |
|
|
44 |
/** |
/** |
|
* TableModelEvent |
|
45 |
* @author Andrew Selkirk |
* @author Andrew Selkirk |
46 |
*/ |
*/ |
47 |
public class TableModelEvent extends EventObject { |
public class TableModelEvent extends EventObject |
48 |
|
{ |
49 |
//------------------------------------------------------------- |
private static final serialVersionUID = -7037680193569691706L; |
50 |
// Constants -------------------------------------------------- |
|
51 |
//------------------------------------------------------------- |
public static int ALL_COLUMNS = -1; |
52 |
|
public static int DELETE = -1; |
53 |
/** |
public static int HEADER_ROW = -1; |
54 |
* ALL_COLUMNS |
public static int INSERT = 1; |
55 |
*/ |
public static int UPDATE = 0; |
56 |
public static int ALL_COLUMNS = -1; |
|
57 |
|
protected int column = 0; |
58 |
/** |
protected int firstRow = 0; |
59 |
* DELETE |
protected int lastRow = 0; |
60 |
*/ |
protected int type = 0; |
61 |
public static int DELETE = -1; |
|
62 |
|
/** |
63 |
/** |
* Creates a <code>TableModelEvent</code> event. |
64 |
* HEADER_ROW |
* |
65 |
*/ |
* @param source The source object |
66 |
public static int HEADER_ROW = -1; |
*/ |
67 |
|
public TableModelEvent(TableModel source) |
68 |
/** |
{ |
69 |
* INSERT |
this(source, 0, source.getRowCount(), ALL_COLUMNS, UPDATE); |
70 |
*/ |
} |
71 |
public static int INSERT = 1; |
|
72 |
|
/** |
73 |
/** |
* Creates a <code>TableModelEvent</code> event. |
74 |
* UPDATE |
* |
75 |
*/ |
* @param source The source object |
76 |
public static int UPDATE = 0; |
* @param row The updated row |
77 |
|
*/ |
78 |
|
public TableModelEvent(TableModel source, int row) |
79 |
//------------------------------------------------------------- |
{ |
80 |
// Variables -------------------------------------------------- |
this(source, row, row, ALL_COLUMNS, UPDATE); |
81 |
//------------------------------------------------------------- |
} |
82 |
|
|
83 |
/** |
/** |
84 |
* column |
* Creates a <code>TableModelEvent</code> event. |
85 |
*/ |
* |
86 |
protected int column = 0; |
* @param source The source object |
87 |
|
* @param firstRow The first row of update |
88 |
/** |
* @param lastRow The last row of update |
89 |
* firstRow |
*/ |
90 |
*/ |
public TableModelEvent(TableModel source, int firstRow, int lastRow) |
91 |
protected int firstRow = 0; |
{ |
92 |
|
this(source, firstRow, lastRow, ALL_COLUMNS, UPDATE); |
93 |
/** |
} |
94 |
* lastRow |
|
95 |
*/ |
/** |
96 |
protected int lastRow = 0; |
* Creates a <code>TableModelEvent</code> event. |
97 |
|
* |
98 |
/** |
* @param source The source object |
99 |
* type |
* @param firstRow The first row of update |
100 |
*/ |
* @param lastRow The last row of update |
101 |
protected int type = 0; |
* @param column The affected column |
102 |
|
*/ |
103 |
|
public TableModelEvent(TableModel source, int firstRow, int lastRow, int column) |
104 |
//------------------------------------------------------------- |
{ |
105 |
// Initialization --------------------------------------------- |
this(source, firstRow, lastRow, column, UPDATE); |
106 |
//------------------------------------------------------------- |
} |
107 |
|
|
108 |
/** |
/** |
109 |
* Constructor TableModelEvent |
* Creates a <code>TableModelEvent</code> event. |
110 |
* @param source Source object |
* |
111 |
*/ |
* @param source The source object |
112 |
public TableModelEvent(TableModel source) { |
* @param firstRow The first row of update |
113 |
this(source, 0, source.getRowCount(), ALL_COLUMNS, UPDATE); |
* @param lastRow The last row of update |
114 |
} // TableModelEvent() |
* @param column The affected column |
115 |
|
* @param type The type of change |
116 |
/** |
*/ |
117 |
* Constructor TableModelEvent |
public TableModelEvent(TableModel source, int firstRow, int lastRow, int column, int type) |
118 |
* @param source Source table model |
{ |
119 |
* @param row Updated row |
super(source); |
120 |
*/ |
this.firstRow = firstRow; |
121 |
public TableModelEvent(TableModel source, int row) { |
this.lastRow = lastRow; |
122 |
this(source, row, row, ALL_COLUMNS, UPDATE); |
this.column = column; |
123 |
} // TableModelEvent() |
this.type = type; |
124 |
|
} |
125 |
/** |
|
126 |
* Constructor TableModelEvent |
/** |
127 |
* @param source Source table model |
* Returns the affected column of this event. |
128 |
* @param firstRow First row of update |
*/ |
129 |
* @param lastRow Last row of update |
public int getColumn() |
130 |
*/ |
{ |
131 |
public TableModelEvent(TableModel source, int firstRow, |
return column; |
132 |
int lastRow) { |
} |
133 |
this(source, firstRow, lastRow, ALL_COLUMNS, UPDATE); |
|
134 |
} // TableModelEvent() |
/** |
135 |
|
* Returns the first affected row of this event. |
136 |
/** |
*/ |
137 |
* Constructor TableModelEvent |
public int getFirstRow() |
138 |
* @param source Source table model |
{ |
139 |
* @param firstRow First row of update |
return firstRow; |
140 |
* @param lastRow Last row of update |
} |
141 |
* @param column Affected column |
|
142 |
*/ |
/** |
143 |
public TableModelEvent(TableModel source, int firstRow, |
* Returns the last affected row of this event. |
144 |
int lastRow, int column) { |
*/ |
145 |
this(source, firstRow, lastRow, column, UPDATE); |
public int getLastRow() |
146 |
} // TableModelEvent() |
{ |
147 |
|
return lastRow; |
148 |
/** |
} |
149 |
* Constructor TableModelEvent |
|
150 |
* @param source Source table model |
/** |
151 |
* @param firstRow First row of update |
* Returns the type of change of this event. |
152 |
* @param lastRow Last row of update |
*/ |
153 |
* @param column Affected column |
public int getType() |
154 |
* @param type Type of change |
{ |
155 |
*/ |
return type; |
156 |
public TableModelEvent(TableModel source, int firstRow, |
} |
157 |
int lastRow, int column, int type) { |
} |
|
super(source); |
|
|
this.firstRow = firstRow; |
|
|
this.lastRow = lastRow; |
|
|
this.column = column; |
|
|
this.type = type; |
|
|
} // TableModelEvent() |
|
|
|
|
|
|
|
|
//------------------------------------------------------------- |
|
|
// Methods ---------------------------------------------------- |
|
|
//------------------------------------------------------------- |
|
|
|
|
|
/** |
|
|
* getColumn |
|
|
* @returns column |
|
|
*/ |
|
|
public int getColumn() { |
|
|
return column; |
|
|
} // getColumn() |
|
|
|
|
|
/** |
|
|
* getFirstRow |
|
|
* @returns row |
|
|
*/ |
|
|
public int getFirstRow() { |
|
|
return firstRow; |
|
|
} // getFirstRow() |
|
|
|
|
|
/** |
|
|
* getLastRow |
|
|
* @returns row |
|
|
*/ |
|
|
public int getLastRow() { |
|
|
return lastRow; |
|
|
} // getLastRow() |
|
|
|
|
|
/** |
|
|
* Get type |
|
|
* @returns Type of event |
|
|
*/ |
|
|
public int getType() { |
|
|
return type; |
|
|
} // getType() |
|
|
|
|
|
|
|
|
} // TableModelEvent |
|