206 |
return new MouseInputHandler(); |
return new MouseInputHandler(); |
207 |
} |
} |
208 |
|
|
209 |
|
/** |
210 |
|
* Return the maximum size of the table. The maximum height is the row |
211 |
|
* height times the number of rows. The maximum width is the sum of |
212 |
|
* the maximum widths of each column. |
213 |
|
* |
214 |
|
* @param comp the component whose maximum size is being queried, |
215 |
|
* this is ignored. |
216 |
|
* @return a Dimension object representing the maximum size of the table, |
217 |
|
* or null if the table has no elements. |
218 |
|
*/ |
219 |
public Dimension getMaximumSize(JComponent comp) |
public Dimension getMaximumSize(JComponent comp) |
220 |
{ |
{ |
221 |
return getPreferredSize(comp); |
int maxTotalColumnWidth = 0; |
222 |
|
for (int i = 0; i < table.getColumnCount(); i++) |
223 |
|
maxTotalColumnWidth += table.getColumnModel().getColumn(i).getMaxWidth(); |
224 |
|
if (maxTotalColumnWidth == 0 || table.getRowCount() == 0) |
225 |
|
return null; |
226 |
|
return new Dimension(maxTotalColumnWidth, table.getRowCount()*table.getRowHeight()); |
227 |
} |
} |
228 |
|
|
229 |
|
/** |
230 |
|
* Return the minimum size of the table. The minimum height is the row |
231 |
|
* height times the number of rows. The minimum width is the sum of |
232 |
|
* the minimum widths of each column. |
233 |
|
* |
234 |
|
* @param comp the component whose minimum size is being queried, |
235 |
|
* this is ignored. |
236 |
|
* @return a Dimension object representing the minimum size of the table, |
237 |
|
* or null if the table has no elements. |
238 |
|
*/ |
239 |
public Dimension getMinimumSize(JComponent comp) |
public Dimension getMinimumSize(JComponent comp) |
240 |
{ |
{ |
241 |
return getPreferredSize(comp); |
int minTotalColumnWidth = 0; |
242 |
|
for (int i = 0; i < table.getColumnCount(); i++) |
243 |
|
minTotalColumnWidth += table.getColumnModel().getColumn(i).getMinWidth(); |
244 |
|
if (minTotalColumnWidth == 0 || table.getRowCount() == 0) |
245 |
|
return null; |
246 |
|
return new Dimension(minTotalColumnWidth, table.getRowCount()*table.getRowHeight()); |
247 |
} |
} |
248 |
|
|
249 |
public Dimension getPreferredSize(JComponent comp) |
public Dimension getPreferredSize(JComponent comp) |
385 |
{ |
{ |
386 |
ListSelectionModel rowModel = table.getSelectionModel(); |
ListSelectionModel rowModel = table.getSelectionModel(); |
387 |
ListSelectionModel colModel = table.getColumnModel().getSelectionModel(); |
ListSelectionModel colModel = table.getColumnModel().getSelectionModel(); |
388 |
|
|
389 |
int rowLead = rowModel.getLeadSelectionIndex(); |
int rowLead = rowModel.getLeadSelectionIndex(); |
390 |
int rowMax = table.getModel().getRowCount() - 1; |
int rowMax = table.getModel().getRowCount() - 1; |
391 |
|
|