-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.0
-
x86
-
windows_2000
Name: bsC130419 Date: 06/05/2001
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
The selection does not occur properly when Rolling a Date Type Value in a
JFormattedTextField when FULL Dateformat is selected. Following code
demonstrates the problem:
import java.awt.*;
import javax.swing.*;
import java.util.Date;
import java.awt.event.*;
import javax.swing.text.*;
import javax.swing.event.*;
import java.text.DateFormat;
public class JFTFSelectionBugFrame extends JFrame {
DateFormat dateFormat;
JFormattedTextField jftf;
private WindowListener windowListener=new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
}
};
public JFTFSelectionBugFrame () {
init();
addWindowListener(windowListener);
setSize(200,250);
}
private void init(){
dateFormat=DateFormat.getDateInstance(DateFormat.FULL);
jftf=new JFormattedTextField(dateFormat);
jftf.setValue(new Date());
getContentPane().setLayout(new FlowLayout());
getContentPane().add(jftf);
}
public static void main(String[] args) {
JFTFSelectionBugFrame frm=new JFTFSelectionBugFrame ();
frm.show();
}
}
////////////////////////////////////////////////////////////////
The above code shows a Frame with a FormattedTextField placed in it and when
you start rolling the month or any other field, selection does not happen as
expected.
I have gone through the code of javax.swing.text.DefaultFormatter,
InternationalFormatter and DateFormatter and found out that when
IncrementAction.actionPerformed in InternationalFomatter.Filter Class is
called, it calls adjustValue(). After that it calls resetValue which calls
updateMaskIfNecessary. Here the iterator that is stored in the
InternationalFormatter.Filter class is not updated because the specified
condition i.e.
if (!getAllowsInvalid() && (getFormat() != null))
in the beginning of updateMaskIfNecessary is not met. This is causing the
problem.
(Review ID: 125870)
======================================================================
- duplicates
-
JDK-4434198 Month not selected properly with cursoring in JFormattedTextField (Date format)
-
- Closed
-