JFormattedTextField extends JTextField adding support for formatting arbitrary values, as well as retrieving a particular object once the user has edited the text.
Questions tagged [jformattedtextfield]
283 questions
18
votes
3 answers
Why is JFormattedTextField evil?
In this question Is there any way to accept only numeric values in a JTextField? one of the answers suggested that JFormattedTextField had issues.
I've not yet used it, but could somebody please expand (or disagree) on the issues with this class?

kwutchak
- 1,022
- 3
- 11
- 22
16
votes
6 answers
How to rendering fraction in Swing JComponents
Basically Swing JComponents are able to display numbers in fractions in this form 2 2/3. How can I paint fraction in the nicest form, for example 2⅔?
.
EDIT
.
as see I have only one way JTable inside JSpinner with one TableColumn and TableRow (that…

mKorbel
- 109,525
- 20
- 134
- 319
12
votes
2 answers
putting "On Change" listener on jFormattedTextField
I have a jFormattedTextField in my program and I need to update a jLabel's text when jFormattedTextField value has been changed validly.
Actually jFormattedTextField gets a number and jLabel displays diffrence between this number and another…

Ariyan
- 14,760
- 31
- 112
- 175
9
votes
2 answers
NumberFormat parse not strict enough
I have a JFormattedTextField with a NumberFormat with Locale.US. So the decimal separator is the point and the grouping separator is the comma.
Now I type the string "1,23" in this text field and move the focus to another component. I would expect…

General Martok
- 175
- 1
- 6
8
votes
1 answer
JFormattedTextField issues
1) how can I set Cursor to 0 possition without using Caret or Focus wrapped into invokeLater() (confortly can be solved by using @camickr Formatted Text Field Tips), is there somebody who knows another way
2) How to reset Formatter sometimes (by…

mKorbel
- 109,525
- 20
- 134
- 319
8
votes
3 answers
FocusEvent doesn't get the last value of JFormattedTextField, How I can get it?
I have two JFormattedTextField objects on my JFrame object. I want a basic Math (addition) by the values of these JFormattedTextField objects. I want it happen when focus lost either the first or the second textfield. But when "focusLost()", event…

Yasin Okumuş
- 2,299
- 7
- 31
- 62
7
votes
4 answers
JFormattedTextField caret position on focus
I am utilizing a few JFormattedTextFields in my program. For some reason when the text field gains focus after a click on the text field, the caret position always jumps to the left (position 0). I would like the caret to end up at the location…

SharpBarb
- 1,590
- 3
- 16
- 40
6
votes
1 answer
JFormattedTextField using a regular expression formatter?
After much frustration with getting a JFormattedTextField to work with my custom formats, I was wondering if there was a Formatter or FormatterFactory that uses regular expressions?
My idea is that if there is one, then I could wrap it in a static…

bguiz
- 27,371
- 47
- 154
- 243
6
votes
1 answer
Swing - MaskFormatter - Enter Numbers from Right side of the textfield
I'm new to Swing Java development. Can some one help me on this.
I have a jformattedtextfield with maskformatter. it works just fine. But only thing i would like to know is if we can make this to enter the numbers from right. The below code works…

Steve
- 71
- 4
6
votes
2 answers
trouble with deleting in masks in a JFormattedTextField
I am having trouble with masks in a JFormattedTextField
I understand that it replaces invalid characters with a space,
or whatever you define via setPlaceholderCharacter,
but what I need it to do is allow deletion or backspace,
and NOT insert a…

Andy Dingfelder
- 2,090
- 2
- 18
- 30
6
votes
2 answers
Strict 24-hour time in JFormattedTextField
I am trying to create a JFormattedTextField that only accepts a 24-hour time.
I am very close to a solution, but have one case where the following code example does not work.
If you enter the time "222" and change focus from the field, the time is…

FuryComputers
- 896
- 2
- 12
- 23
5
votes
1 answer
How to set jFormattedTextField so it only allows 2 numbers?
I'm a beginner in Java, and NetBeans. I'm trying to make a simple program where you introduce 2 numbers and their sum gets divided by two. However, I'm using JFormattedTExtFields and I don't know how to customize the allowed input in them. Basically…

Bugster
- 1,552
- 8
- 34
- 56
5
votes
0 answers
optional character with MaskFormatter java
I need a simple thing.
I have a JFormattedTextField with MaskFormatter "##" but I want the first digit is optional.
The information I want to get is the day of the month.
Thanks.

PCampello
- 167
- 2
- 8
5
votes
1 answer
Swing: JFormattedTextField set to numbers only using Netbeans
I've got a little problem with JFormattedTextField:
I want to set the formatted text fields to numbers only. I've created one with Swing interface on NetBeans.
My code is as follows:
package SerasApp;
import static java.lang.System.*;
import…

Adam Dong
- 53
- 1
- 1
- 4
5
votes
4 answers
How to make JFormattedTextField accept integer without decimal point (comma)?
I used JFormattedTextField withNumberFormat in this way:
-Creat a JFormattedTextField refernce
JFormattedTextField integerField;
-Create a NumberFormat refernce
NumberFormat integerFieldFormatter;
-In the constructor:
integerFieldFormatter =…

Saleh Feek
- 2,048
- 8
- 34
- 56