647 |
this.rowSelectionAllowed = true; |
this.rowSelectionAllowed = true; |
648 |
// this.accessibleContext = new AccessibleJTable(); |
// this.accessibleContext = new AccessibleJTable(); |
649 |
this.cellEditor = null; |
this.cellEditor = null; |
650 |
this.dragEnabled = false; |
// COMPAT: Both Sun and IBM have drag enabled |
651 |
|
this.dragEnabled = true; |
652 |
this.preferredViewportSize = new Dimension(450,400); |
this.preferredViewportSize = new Dimension(450,400); |
653 |
this.showHorizontalLines = true; |
this.showHorizontalLines = true; |
654 |
this.showVerticalLines = true; |
this.showVerticalLines = true; |
914 |
*/ |
*/ |
915 |
public ListSelectionModel getSelectionModel() |
public ListSelectionModel getSelectionModel() |
916 |
{ |
{ |
917 |
if (! rowSelectionAllowed) |
//Neither Sun nor IBM returns null if rowSelection not allowed |
|
return null; |
|
|
|
|
918 |
return selectionModel; |
return selectionModel; |
919 |
} |
} |
920 |
|
|
2078 |
{ |
{ |
2079 |
return columnModel.getColumn(columnModel.getColumnIndex(identifier)); |
return columnModel.getColumn(columnModel.getColumnIndex(identifier)); |
2080 |
} |
} |
2081 |
|
|
2082 |
|
public void changeSelection (int rowIndex, int columnIndex, boolean toggle, boolean extend) |
2083 |
|
{ |
2084 |
|
if (toggle && extend) |
2085 |
|
{ |
2086 |
|
// Leave the selection state as is, but move the anchor |
2087 |
|
// index to the specified location |
2088 |
|
selectionModel.setAnchorSelectionIndex(rowIndex); |
2089 |
|
getColumnModel().getSelectionModel().setAnchorSelectionIndex(columnIndex); |
2090 |
|
} |
2091 |
|
else if (toggle) |
2092 |
|
{ |
2093 |
|
// Toggle the state of the specified cell |
2094 |
|
if (isCellSelected(rowIndex,columnIndex)) |
2095 |
|
{ |
2096 |
|
selectionModel.removeSelectionInterval(rowIndex,rowIndex); |
2097 |
|
getColumnModel().getSelectionModel().removeSelectionInterval(columnIndex,columnIndex); |
2098 |
|
} |
2099 |
|
else |
2100 |
|
{ |
2101 |
|
selectionModel.addSelectionInterval(rowIndex,rowIndex); |
2102 |
|
getColumnModel().getSelectionModel().addSelectionInterval(columnIndex,columnIndex); |
2103 |
|
} |
2104 |
|
} |
2105 |
|
else if (extend) |
2106 |
|
{ |
2107 |
|
// Extend the previous selection from the anchor to the |
2108 |
|
// specified cell, clearing all other selections |
2109 |
|
selectionModel.setLeadSelectionIndex(rowIndex); |
2110 |
|
getColumnModel().getSelectionModel().setLeadSelectionIndex(columnIndex); |
2111 |
|
} |
2112 |
|
else |
2113 |
|
{ |
2114 |
|
// Clear the previous selection and ensure the new cell |
2115 |
|
// is selected |
2116 |
|
selectionModel.clearSelection(); |
2117 |
|
selectionModel.setSelectionInterval(rowIndex,rowIndex); |
2118 |
|
getColumnModel().getSelectionModel().clearSelection(); |
2119 |
|
getColumnModel().getSelectionModel().setSelectionInterval(columnIndex, columnIndex); |
2120 |
|
|
2121 |
|
|
2122 |
|
} |
2123 |
|
} |
2124 |
} |
} |