Results 1 to 8 of 8
  1. #1
    itaipee is offline Member
    Join Date
    Dec 2008
    Posts
    99
    Rep Power
    0

    Default JtextFormmatedfields: How to remove the "," in the number

    Hi

    I'm using JFormattedField for textfield with number only.
    Java 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 ?

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    832
    Rep Power
    6

    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:cool:

  3. #3
    itaipee is offline Member
    Join Date
    Dec 2008
    Posts
    99
    Rep Power
    0

    Default

    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.

  4. #4
    Supamagier is offline Senior Member
    Join Date
    Aug 2008
    Posts
    384
    Rep Power
    6

    Default

    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.

  5. #5
    itaipee is offline Member
    Join Date
    Dec 2008
    Posts
    99
    Rep Power
    0

    Default

    Quote 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"

  6. #6
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    832
    Rep Power
    6

    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:cool:

  7. #7
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    9

    Default

    Java Code:
    numFormat = NumberFormat.getIntegerInstance();
    numFormat.setGroupingUsed(false);

  8. #8
    itaipee is offline Member
    Join Date
    Dec 2008
    Posts
    99
    Rep Power
    0

Similar Threads

  1. Java, Military Format using "/" and "%" Operator!!
    By sk8rsam77 in forum New To Java
    Replies: 11
    Last Post: 02-26-2010, 03:03 AM
  2. Replies: 2
    Last Post: 01-24-2009, 06:56 PM
  3. Replies: 1
    Last Post: 10-20-2008, 07:35 AM
  4. "Jumble" or "Scramble" Program
    By Shadow22202 in forum Java Applets
    Replies: 8
    Last Post: 04-30-2008, 03:42 AM
  5. "Error in number, try again."
    By finlandssvensk in forum New To Java
    Replies: 1
    Last Post: 11-26-2007, 10:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •