-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.0, 1.4.1_02, 1.4.2
-
x86
-
windows_2000, windows_xp
Name: jk109818 Date: 05/27/2003
FULL PRODUCT VERSION :
Tested on:
java version "1.4.0_03"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_03-b04)
Java HotSpot(TM) Client VM (build 1.4.0_03-b04, mixed mode)
java version "1.4.0_04"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_04-b04)
Java HotSpot(TM) Client VM (build 1.4.0_04-b04, mixed mode)
jav
java version "1.4.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)
java version "1.4.2-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19)
Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode)
FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
When selecting something in a JFormattedTextField that isnt focusowner, selection starts at text start.
In the sample:
1. Set focus in the first JFormattedTextField.
2. Using the mouse; try to select the text "23" in the second JFormattedTextField.
This is not possible without first clicking on the second JFormattedTextField and then selecting.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Selected "23"
ACTUAL -
Selection became "123"
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Tester {
public static void main(String[] args) {
JFrame frame = new JFrame("Tester");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
JPanel panel = new JPanel();
JFormattedTextField tx1 = new JFormattedTextField("ABC");
JFormattedTextField tx2 = new JFormattedTextField("123");
panel.add(tx1);
panel.add(tx2);
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Installing a FocusListner on the JFormattedTextFields and setting the caret position in an invokelater does it.
tx1.addFocusListener(this);
tx2.addFocusListener(this);
public void focusGained(final FocusEvent e) {
final int i = ((JFormattedTextField)e.getComponent()).getCaret().getDot();
SwingUtilities.invokeLater(new Runnable() {
public void run() {
((JFormattedTextField)e.getComponent()).getCaret().setDot(i);
}
});
}
(Review ID: 186097)
======================================================================
- duplicates
-
JDK-4699955 JSpinner focusGained(...) listener does not allow selectAll functionality
-
- Closed
-