|
Quick Lists
|
|
Bug ID:
|
4303294
|
|
Votes
|
6
|
|
Synopsis
|
Implement discontinuous selection from the keyboard for list-like components
|
|
Category
|
java:classes_swing
|
|
Reported Against
|
1.3
, 1.4
, 1.2.2
, 1.4.1
, merlin-beta
|
|
Release Fixed
|
1.5(tiger)
|
|
State
|
10-Fix Delivered,
request for enhancement
|
|
Priority:
|
4-Low
|
|
Related Bugs
|
4251000
,
4337119
,
4630835
,
4759422
,
4849062
,
4908734
,
4386259
,
4820833
,
4907988
,
4976239
|
|
Submit Date
|
07-JAN-2000
|
|
Description
|
What is the feature and what problem is it solving?:
It is currently not possible to select discontinuous component from a list-like
component. This significantly degrades access for disabled users must use a
keyboard for an input device.
How will it work?:
Implement discontinuous selection in list-like components. This will probably
require one or more API changes to Swing components.
What are the benefits over other solutions?:
(not applicable)
======================================================================
xxxxx@xxxxx 11/2/04 16:38 GMT
|
|
Work Around
|
N/A
|
|
Evaluation
|
Should implement for Merlin.
xxxxx@xxxxx 2000-01-14
Committing to merlin release
======================================================================
As this requires a change to either the DefaultListSelectionModel, or a new ListSelectionModel, I'm reassigning to Swing.
xxxxx@xxxxx 2001-11-28
Just a reminder that we should take a look at 4759422 when fixing this bug, as it also deals with keyboard navigation/selection (in JTable).
xxxxx@xxxxx 2003-06-24
This bug has now been fixed. Here's a summary:
JList, JTable, and JTree all now support discontinuous selection through the keyboard. It is available when the component is in discontiguous selection mode (see ListSelectionModel.MULTIPLE_INTERVAL_SELECTION and TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION).
With JTable and JList, the new behavior is only enabled if the underlying selection models are instances of DefaultListSelectionModel.
When discontinuous selection is enabled, the keyboard user can manipulate the lead index without changing the selection. New key bindings have been added to the UIs to enable this. These bindings are typically the same as the bindings that move the selection, with the addition of a modifier key. (For example, with JList in the Windows look and feel: UP moves the selection up / CTRL-UP moves just the lead up. END moves the selection to the end of the list / CTRL-END moves just the lead to the end of the list). New key bindings have also been added to add/remove items from the selection (For example, with JList in the Windows look and feel, SPACE, CTRL-SPACE, SHIFT-SPACE, CTRL-SHIFT-SPACE have all been implemented to modify the selection as they would on a native Windows list).
As much as possible, the selection behavior of JList, JTable, and JTree has been made consistent.
As part of this change, JTable was modified such that it now treats the lead, rather than the anchor, as the focused item. This was necessary to facilitate discontinuous selection and to make JTable consistent with JList and JTree. This problem was reported separately as 4759422 (*** more below ***) but has been folded into this bug.
Lastly, as part of this fix, a handful of things have been cleaned up with respect to the selection behavior in the three components. For example, I beleive that selectAll and unselectAll behavior now acts like users would expect.
xxxxx@xxxxx 2003-08-08
*** 4849062, which reports the same issue as 4759422, has also been closed as a duplicate of this bug. ***
xxxxx@xxxxx 2003-08-13
|
|
Comments
|
Submitted On 06-OCT-2005
vivgfuller
Below is a program which modifies the JList to allow alternate selection using keyboard.
package com.test;
import java.awt.FlowLayout;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.DefaultListSelectionModel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JList;
public class Sample {
DefaultListSelectionModel listSelectionModel;
JList list;
public Sample(){
String items[] = {"Ravens","Eagles","Redskins","Patriots","Jets","Bills","Giants", "Falcon", "49ers", "Cowboys"};
list = new JList(items);
listSelectionModel = new DefaultListSelectionModel();
}
public void show(){
JFrame frame = new JFrame();
list.setSelectionModel(listSelectionModel);
list.setSize(100,100);
list.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent ke){
if(ke.isControlDown() ) {
int anchor = list.getAnchorSelectionIndex();
if(ke.getKeyCode() == KeyEvent.VK_DOWN){
if (!list.isSelectedIndex(Math.min(10,anchor + 1))) {
list.removeSelectionInterval(Math.min(10,anchor + 1), Math.min(10,anchor + 1));
}
listSelectionModel.setAnchorSelectionIndex(Math.min(10,anchor + 1));
}
else if (ke.getKeyCode() == KeyEvent.VK_UP){
if (!list.isSelectedIndex(Math.max(anchor-1,0))) {
list.removeSelectionInterval(Math.max(anchor-1,0), Math.max(anchor-1,0));
}
listSelectionModel.setAnchorSelectionIndex(Math.max(anchor-1,0));
}
else if (ke.getKeyCode() == KeyEvent.VK_SPACE){
if (list.isSelectedIndex(anchor)) {
list.removeSelectionInterval(anchor, anchor);
}
else {
list.addSelectionInterval(anchor, anchor);
}
}
}
//ke.consume();
}
});
frame.getContentPane().setLayout(new FlowLayout());
frame.getContentPane().add(list);
JButton bOK = new JButton("OK");
frame.getContentPane().add(bOK);
frame.setSize(450,280);
frame.setVisible(true);
}
public static void main(String[] args){
System.out.println("Test.......");
new Sample().show();
}
}
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |