-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
6
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Unable programmatically select text in JFormattedTextField.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and execute the test.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Text in JTextField and in JFormattedTextField is selected.
ACTUAL -
Text selected ONLY in JTextField.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
import java.text.NumberFormat;
public class JFormattedTextFieldTest extends JFrame {
public JFormattedTextFieldTest() throws HeadlessException {
super("test");
setLayout(new FlowLayout());
JLabel textFieldLabel = new JLabel("JTextField:");
add(textFieldLabel);
JTextField textField = new JTextField();
textField.setText("abcdefgh");
textField.setSelectionStart(0);
textField.setSelectionEnd(textField.getText().length());
add(textField);
JLabel formattedTextFeildLabel = new JLabel("JFormattedTextField:");
add(formattedTextFeildLabel);
NumberFormat format = NumberFormat.getIntegerInstance();
format.setGroupingUsed(false);
JFormattedTextField formattedTextField = new JFormattedTextField(format);
formattedTextField.setValue(1000);
formattedTextField.setSelectionStart(0);
formattedTextField.setSelectionEnd(formattedTextField.getText().length());
add(formattedTextField);
}
public static void initAndShow() {
JFormattedTextFieldTest test = new JFormattedTextFieldTest();
test.pack();
test.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
initAndShow();
}
});
}
}
---------- END SOURCE ----------
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
Unable programmatically select text in JFormattedTextField.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and execute the test.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Text in JTextField and in JFormattedTextField is selected.
ACTUAL -
Text selected ONLY in JTextField.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.*;
import java.text.NumberFormat;
public class JFormattedTextFieldTest extends JFrame {
public JFormattedTextFieldTest() throws HeadlessException {
super("test");
setLayout(new FlowLayout());
JLabel textFieldLabel = new JLabel("JTextField:");
add(textFieldLabel);
JTextField textField = new JTextField();
textField.setText("abcdefgh");
textField.setSelectionStart(0);
textField.setSelectionEnd(textField.getText().length());
add(textField);
JLabel formattedTextFeildLabel = new JLabel("JFormattedTextField:");
add(formattedTextFeildLabel);
NumberFormat format = NumberFormat.getIntegerInstance();
format.setGroupingUsed(false);
JFormattedTextField formattedTextField = new JFormattedTextField(format);
formattedTextField.setValue(1000);
formattedTextField.setSelectionStart(0);
formattedTextField.setSelectionEnd(formattedTextField.getText().length());
add(formattedTextField);
}
public static void initAndShow() {
JFormattedTextFieldTest test = new JFormattedTextFieldTest();
test.pack();
test.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
initAndShow();
}
});
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-6575394 setCaretPosition and select not working in JFormattedTextField
-
- Closed
-