-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
beta
-
sparc
-
solaris_2.6
Name: nkR10003 Date: 10/16/2000
JavaDoc comments for method BasicListUI.installKeyboardActions state:
"... The actions just call out to protected methods, subclasses that
want to override or extend keyboard behavior should consider
just overriding those methods. This method is called at
installUI() time.
@see #selectPreviousIndex
@see #selectNextIndex
@see #installUI"
Actually overriding of selectPreviousIndex() and selectNextIndex()
methods has no effect.
Example below demonstrates this problem:
------------------example--------------------
import javax.swing.plaf.basic.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.Window;
class StubListUI extends BasicListUI {
public StubListUI() {
super();
}
protected void selectPreviousIndex() {
System.out.println("select previous index");
System.out.flush();
super.selectPreviousIndex();
}
protected void selectNextIndex() {
System.out.println("select next index");
System.out.flush();
super.selectPreviousIndex();
}
}
public class test {
public static void main(String[] args) {
String[] data = {"one", "two", "three", "four", "five"};
JList list = new JList(data);
list.setSelectedIndex(0);
StubListUI ui = new StubListUI();
list.setUI(ui);
JFrame frame = new JFrame("Test");
frame.getContentPane().add(list);
frame.setSize(100,
(int)list.getPreferredScrollableViewportSize().
getHeight());
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
Window w = e.getWindow();
w.setVisible(false);
w.dispose();
System.out.println("Finish");
System.out.flush();
System.exit(0);
}
});
frame.setVisible(true);
}
}
----------------output:----------------------
Finish
---------------------------------------------
How to run the test:
Compile and run example. Move the list selection with the arrow buttons.
This actions should cause calls to selectPrevious(Next)Index methods
and thus printing messages to System.out.
======================================================================