-
Backport
-
Resolution: Fixed
-
P2
-
None
-
b09
-
Not verified
Having a queue of LW requests, all of the same heavyweight. The process of clearing the queue (see
KFM.processCurrentLightweightRequests) can break the focus system, if some of the requests (not the
last in the queue) gets failed (i.e. doesn't set a target component to the focus owner). In this case
all the markers (that map to the requests undispatched) are left unremoved. The result is clear.
Another effect of this behaviour is that the target component of the last LW request in the queue
will not get focus, that is not expected result (from user's perspective).
Run the test below:
1. You'll see a frame.
2. Click the button in the frame:
Expected: focus should come to the "text2".
Actual: focus returns to the button.
3. Click in the "text2" (if it's not focused)
4. Try to type:
Expected: typing appears in the text field.
Actual: nothing appears
If 4'th failed, click in the "text3", the chars typed will appear there.
---------------------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JRequestTest {
static JFrame f1 = new JFrame("frame");
static JFrame f2 = new JFrame("frame");
static JButton b = new JButton("button");
static JTextField tf1 = new JTextField("text1");
static JTextField tf2 = new JTextField("text2");
static JTextField tf3 = new JTextField("text3");
public static void main(String[] args) {
f1.add(b);
f1.add(tf1);
f1.add(tf2);
f1.add(tf3);
f1.setLayout(new FlowLayout());
f1.pack();
f1.setVisible(true);
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
f2.setVisible(true);
}
});
f2.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
b.requestFocus();
tf1.requestFocus();
tf1.setFocusable(false);
tf2.requestFocus();
}
});
}
}
--------------------------------------------------------
KFM.processCurrentLightweightRequests) can break the focus system, if some of the requests (not the
last in the queue) gets failed (i.e. doesn't set a target component to the focus owner). In this case
all the markers (that map to the requests undispatched) are left unremoved. The result is clear.
Another effect of this behaviour is that the target component of the last LW request in the queue
will not get focus, that is not expected result (from user's perspective).
Run the test below:
1. You'll see a frame.
2. Click the button in the frame:
Expected: focus should come to the "text2".
Actual: focus returns to the button.
3. Click in the "text2" (if it's not focused)
4. Try to type:
Expected: typing appears in the text field.
Actual: nothing appears
If 4'th failed, click in the "text3", the chars typed will appear there.
---------------------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JRequestTest {
static JFrame f1 = new JFrame("frame");
static JFrame f2 = new JFrame("frame");
static JButton b = new JButton("button");
static JTextField tf1 = new JTextField("text1");
static JTextField tf2 = new JTextField("text2");
static JTextField tf3 = new JTextField("text3");
public static void main(String[] args) {
f1.add(b);
f1.add(tf1);
f1.add(tf2);
f1.add(tf3);
f1.setLayout(new FlowLayout());
f1.pack();
f1.setVisible(true);
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
f2.setVisible(true);
}
});
f2.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
b.requestFocus();
tf1.requestFocus();
tf1.setFocusable(false);
tf2.requestFocus();
}
});
}
}
--------------------------------------------------------
- backport of
-
JDK-6496958 incorrect backoff in the process of dispatching lw requests queue
- Resolved