-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.1.1
-
generic
-
generic
Name: clC74495 Date: 06/02/99
(This is in Swing 1.1.1beta2, but applies to all versions)
The DefaultFocusManager is extremely slow when a container has many children. A testcase is given below.
The finger-of-blame goes to DefaultFocusManager.childrenTabOrder(), which uses a bubble sort[!!]. Replacing the bubble sort with a quick sort made the code about twenty times faster with the below (admittedly, extreme, but not entirely unrealistic) test case.
import java.awt.*;
import javax.swing.*;
public class FocusTest extends JPanel
{
static public void main(String[] args)
{
JFrame frame = new JFrame();
frame.setContentPane(new FocusTest());
frame.pack();
frame.setVisible(true);
}
private FocusTest()
{
setLayout(new GridLayout(30, 30));
for (int i = 0; i < 900; i++)
{
add(new JTextField("Field", 5));
}
}
}
(Review ID: 83175)
======================================================================
- duplicates
-
JDK-4290675 Focus Management Enhancements
- Closed