-
Bug
-
Resolution: Fixed
-
P2
-
1.4.0
-
beta2
-
generic, unknown
-
generic
-
Verified
Name: bsC130419 Date: 06/06/2001
D:\data\edu\java\jdk14>java -version
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b64)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b64, mixed mode)
1. - start attached java program with JDK 1.4 (>java jdk14.ListScrollingTest)
- click into list (select "A one1")
- type Shift-C -> selects item "C one1" instead of "C one0 (Dummy)"
(Reason: "C one0 (Dummy)" is not a String-Object)
2. Source code for test-program used:
----
package jdk14;
import javax.swing.JScrollPane;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import java.util.Vector;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JList;
/**
* Brings up a JList with several (alphabetically sorted) items.
* Used to test first-character scrolling and wheel-mouse-scrolling.
*
* Creation date: (18.05.2001 13:48:05)
* @author: Peter Gassmann (###@###.###)
*/
public class ListScrollingTest extends JFrame {
class Dummy{
private String text_;
public Dummy(String aText){
text_ = aText + " (Dummy)";
}
public String toString(){
return text_;
}
}
/**
* ListScrollingTest constructor comment.
*/
public ListScrollingTest(String aTitle) {
super(aTitle);
initialize();
}
/**
* Insert the method's description here.
* Creation date: (18.05.2001 13:51:29)
*/
private void initialize() {
Vector data = new Vector();
data.add("A one1");
data.add("A one2");
data.add("A one3");
data.add("A one4");
data.add("A one5");
data.add("A one6");
data.add("B one7");
data.add("B one8");
data.add("B one9");
data.add(new Dummy("C one0"));
data.add("C one1");
data.add("C one2");
data.add(new Dummy("D one3"));
data.add("D one4");
data.add("D one5");
data.add("e one6");
data.add("E one7");
data.add("E one8");
data.add("E one9");
data.add(new Dummy("f one0"));
data.add(new Dummy("f one1"));
data.add(new Dummy("F one2"));
data.add("F one3");
data.add("F one4");
data.add("g one5");
data.add("g one6");
data.add("G one7");
data.add("G one8");
data.add("G one9");
data.add("h one0");
data.add("h one1");
data.add("H one2");
data.add("H one3");
data.add("H one4");
data.add("i one5");
data.add("I one6");
data.add("I one7");
data.add("I one8");
data.add("I one9");
JList list = new JList(data);
list.setVisibleRowCount(15);
JPanel panel = new JPanel(new BorderLayout());
panel.add(new JScrollPane(list), BorderLayout.CENTER);
setContentPane(panel);
}
/**
* Starts the application.
* @param args an array of command-line arguments
*/
public static void main(java.lang.String[] args) {
JFrame frame = new ListScrollingTest("frame with list");
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
frame.pack();
frame.setVisible(true);
}
}
----
3. I would expect scrolling to work with non-String objects as well, e.g. use
object.toString() to find item to select.
The problem is due to the code in JList.getNextMatch() and JTree.getNextMatch(),
which uses a typecast to java.lang.String instead of object.toString() to find
the next item to select.
(Review ID: 125063)
======================================================================
- duplicates
-
JDK-4463999 JLists with text & icons should support type-ahead keyboard nagivation
-
- Closed
-