200 |
if (evt.getKeyCode() == KeyEvent.VK_DOWN) |
if (evt.getKeyCode() == KeyEvent.VK_DOWN) |
201 |
{ |
{ |
202 |
int lead = BasicListUI.this.list.getLeadSelectionIndex(); |
int lead = BasicListUI.this.list.getLeadSelectionIndex(); |
203 |
|
int max = BasicListUI.this.list.getModel().getSize() - 1; |
204 |
if (!evt.isShiftDown()) |
if (!evt.isShiftDown()) |
205 |
{ |
{ |
206 |
BasicListUI.this.list.clearSelection(); |
BasicListUI.this.list.clearSelection(); |
207 |
BasicListUI.this.list.setSelectedIndex(lead+1); |
BasicListUI.this.list.setSelectedIndex(Math.min(lead+1,max)); |
208 |
} |
} |
209 |
else |
else |
210 |
{ |
{ |
211 |
BasicListUI.this.list.getSelectionModel().setLeadSelectionIndex(lead+1); |
BasicListUI.this.list.getSelectionModel(). |
212 |
|
setLeadSelectionIndex(Math.min(lead+1,max)); |
213 |
} |
} |
214 |
} |
} |
215 |
else if (evt.getKeyCode() == KeyEvent.VK_UP) |
else if (evt.getKeyCode() == KeyEvent.VK_UP) |
222 |
} |
} |
223 |
else |
else |
224 |
{ |
{ |
225 |
BasicListUI.this.list.getSelectionModel().setLeadSelectionIndex(Math.max(lead-1,0)); |
BasicListUI.this.list.getSelectionModel(). |
226 |
|
setLeadSelectionIndex(Math.max(lead-1,0)); |
227 |
} |
} |
228 |
} |
} |
229 |
} |
} |
247 |
int index = BasicListUI.this.locationToIndex(list, click); |
int index = BasicListUI.this.locationToIndex(list, click); |
248 |
if (index == -1) |
if (index == -1) |
249 |
return; |
return; |
250 |
boolean controlPressed = event.isControlDown(); |
if (event.isControlDown()) |
|
if (controlPressed) |
|
251 |
{ |
{ |
252 |
if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION) |
if (BasicListUI.this.list.getSelectionMode() == |
253 |
|
ListSelectionModel.SINGLE_SELECTION) |
254 |
BasicListUI.this.list.setSelectedIndex(index); |
BasicListUI.this.list.setSelectedIndex(index); |
255 |
else if (BasicListUI.this.list.isSelectedIndex(index)) |
else if (BasicListUI.this.list.isSelectedIndex(index)) |
256 |
BasicListUI.this.list.removeSelectionInterval(index,index); |
BasicListUI.this.list.removeSelectionInterval(index,index); |
257 |
else |
else |
258 |
BasicListUI.this.list.addSelectionInterval(index,index); |
BasicListUI.this.list.addSelectionInterval(index,index); |
259 |
} |
} |
260 |
|
else if (event.isShiftDown()) |
261 |
|
{ |
262 |
|
if (BasicListUI.this.list.getSelectionMode() == |
263 |
|
ListSelectionModel.SINGLE_SELECTION) |
264 |
|
BasicListUI.this.list.setSelectedIndex(index); |
265 |
|
else if (BasicListUI.this.list.getSelectionMode() == |
266 |
|
ListSelectionModel.SINGLE_INTERVAL_SELECTION) |
267 |
|
// COMPAT: the IBM VM is compatible with the following line of code. |
268 |
|
// However, compliance with Sun's VM would correspond to replacing |
269 |
|
// getAnchorSelectionIndex() with getLeadSelectionIndex().This is |
270 |
|
// both unnatural and contradictory to the way they handle other |
271 |
|
// similar UI interactions. |
272 |
|
BasicListUI.this.list.setSelectionInterval |
273 |
|
(BasicListUI.this.list.getAnchorSelectionIndex(), index); |
274 |
|
else |
275 |
|
// COMPAT: both Sun and IBM are compatible instead with: |
276 |
|
// BasicListUI.this.list.setSelectionInterval |
277 |
|
// (BasicListUI.this.list.getLeadSelectionIndex(),index); |
278 |
|
// Note that for IBM this is contradictory to what they did in |
279 |
|
// the above situation for SINGLE_INTERVAL_SELECTION. |
280 |
|
// The most natural thing to do is the following: |
281 |
|
BasicListUI.this.list.getSelectionModel(). |
282 |
|
setLeadSelectionIndex(index); |
283 |
|
} |
284 |
else |
else |
285 |
BasicListUI.this.list.setSelectedIndex(index); |
BasicListUI.this.list.setSelectedIndex(index); |
286 |
} |
} |