Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-09-2009, 10:20 AM
Member
 
Join Date: Dec 2008
Posts: 98
Rep Power: 0
itaipee is on a distinguished road
Default JtextFormmatedfields: How to remove the "," in the number
Hi

I'm using JFormattedField for textfield with number only.
Code:
numFormat = NumberFormat.getNumberInstance();
jTextNumberField = new JFormattedField(numFormat);
number with 4 digits or more are in format "123,456,789" but I dont want the "," - i want "123456789"

How can I do it ?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 06-09-2009, 10:41 AM
RamyaSivakanth's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Chennai
Posts: 589
Rep Power: 1
RamyaSivakanth is on a distinguished road
Default
Replace this "," with "" using String replace function.

Gothru api
-----------
String (Java 2 Platform SE 5.0)


replace(char oldChar, char newChar)
Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar.
__________________
Ramya
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-09-2009, 12:01 PM
Member
 
Join Date: Dec 2008
Posts: 98
Rep Power: 0
itaipee is on a distinguished road
Default
Quote:
Replace this "," with "" using String replace function.
Yes , that what i'm doing so far, in post processing phase .

But I want that the textField itself will be int the desired format.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 06-09-2009, 12:21 PM
Senior Member
 
Join Date: Aug 2008
Posts: 374
Rep Power: 2
Supamagier is on a distinguished road
Default
Quote:
But I want that the textField itself will be int the desired format.
what?

To get the value in a textfield as an int just use Integer.parseInt(TextField.getText());
__________________
I die a little on the inside...
Every time I get shot.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 06-09-2009, 04:07 PM
Member
 
Join Date: Dec 2008
Posts: 98
Rep Power: 0
itaipee is on a distinguished road
Default
Originally Posted by Supamagier View Post
what?

To get the value in a textfield as an int just use Integer.parseInt(TextField.getText());
I have a perl script , ( which not in my control) that read the textfield . the number 12345 is presented in the textfield as "12,345" so the perl script cannot read this variable currectly.
That is a fact that I cannot change.

So I want to have in the JAVA jTextFormattedField format with not "," so 12345 will still be 12345 and not "12,345"
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 06-09-2009, 04:44 PM
RamyaSivakanth's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Chennai
Posts: 589
Rep Power: 1
RamyaSivakanth is on a distinguished road
Default
Hi,
Send the piece of code with comments.I thought the issue is solved but still some major problem in understanding ur req.

-Regards
Ramya
__________________
Ramya
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 06-09-2009, 07:34 PM
hardwired's Avatar
Senior Member
 
Join Date: Jul 2007
Posts: 1,577
Rep Power: 4
hardwired is on a distinguished road
Default
Code:
numFormat = NumberFormat.getIntegerInstance();
numFormat.setGroupingUsed(false);
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 06-10-2009, 10:41 AM
Member
 
Join Date: Dec 2008
Posts: 98
Rep Power: 0
itaipee is on a distinguished road
Default
thanks hardwired , that makes the trick
( SOLVED)
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java, Military Format using "/" and "%" Operator!! sk8rsam77 New To Java 11 02-26-2010 04:03 AM
MoneyOut.println("It took you (whats wrong?>",year,"<WW?) years to repay the loan") soc86 New To Java 2 01-24-2009 07:56 PM
the dollar sign "$", prints like any other normal char in java like "a" or "*" ? lse123 New To Java 1 10-20-2008 08:35 AM
"Jumble" or "Scramble" Program Shadow22202 Java Applets 8 04-30-2008 04:42 AM
"Error in number, try again." finlandssvensk New To Java 1 11-26-2007 11:36 PM


All times are GMT +2. The time now is 02:31 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org