*
The moose likes Swing / AWT / SWT and the fly likes Decimal Format is not setting the value in text field correctly. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Decimal Format is not setting the value in text field correctly." Watch "Decimal Format is not setting the value in text field correctly." New topic
Author

Decimal Format is not setting the value in text field correctly.

Chinmay Kant
Greenhorn

Joined: Feb 04, 2008
Posts: 20
I have a text field which will have only Integer (positive and negative values). So,I am using JFormattedtextField as shown below:-

The getFormatter(0 method is as follows:-

This makes me only type 0 to 9 and - sign iniside the text box.
My Problem:-
I have already a neagtive value like "-1222" inside the text field
[Now using if a set a value which is positive i.e "1234"
then after that i see the result as "-1234"
Here though my value was positive, it did not remove the negative sign
What could be the problem not getting???
Is my formatter wrong??



Thanks and Regards,
Chinmay
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Why not use a JSpinner with a SpinnerNumberModel?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Decimal Format is not setting the value in text field correctly.
 
Similar Threads
Reset of JTextField data
Problem with caret position using JFormattedTextField w/ DefaultFormatter
JTextFormatted TextField
can't set cursor placement when clicking in a JFormattedTextField...
JFormattedTextField MaskFormatter issues: Please Help its urgent