Remove comma from jspinner

jspinner set minimum value
javax swing spinnerdatemodel

Is there anyway to remove the comma from the Jspinner, i'm trying to use it as input for the year but it displays 2011 as 2,011. thanks for the help.

Set the spinner to use a SpinnerDateModel.

java - Remove comma from jspinner, Is there anyway to remove the comma from the Jspinner, i'm trying to use it as input for the year but it displays 2011 as 2,011. thanks for the help. java swing  This will already remove the comma but only display as many digits as necessary. Oh, and I'll move this thread to our GUI forum. SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6

I think this is an easier solution :

JSpinner.NumberEditor editor = new JSpinner.NumberEditor(mySpinner, "#");
mySpinner.setEditor(editor);

Remove comma in the JSpinner (Swing / AWT / SWT forum at , Is there a way that I can remove the commas in a JSpinner. Can I remove the default number editor and implement my own? Post by: Swaranga  Find answers to remove commas from JSpinner from the expert community at Experts Exchange

JSpinner.NumberEditor editor = new JSpinner.NumberEditor( spinner, "#" );
spinner.setEditor( editor );

Hope this will help you.

Java Answers Forum - Get rid of that comma in my JSpinner!!!, Hey, There's gotta be a way to do this: My JSpinner seems to like inserting commas in the numbers I enter when the number's big enough. Hello, I am using a JSpinner with a SpinnerNumberModel to display an integer whose range is 5000 to 9,999 (incremented by 1). The JSpinner shows the current number as an integer with a comma (i.e. 6,300). Is there an easy way to remove the comma from the JSpinners display? (i.e 6300). Thanks! Michelle

Or you can do these in Netbeans in few clicks.

select the jspinner component (the one you dragged)

properties >> editor >> change the type to Number and format to 0000.

:D

remove commas from JSpinner Solutions, Hi I am currently using JSpinner to inside one of my GUI apps. It would be very convenient to be able to remove the commas from the numbers. I would like to allow both "comma" and "dot" as separator in double. I could use replace method in string to get only one separator, but problem is that double value is value of JSpinner and I was not able to find any method to allow both separators. If I set locale for example to French only one separator is allowed.

JSpinner « Component « Java Swing Q&A, Remove comma in the JSpinner coderanch.com. Exception in thread "AWT-​EventQueue-0" java.lang.ClassCastException: java.lang.Integer cannot be cast to  It is required to create a JSpinner with following features. Range should be 0 to 1000 with 10 increment. Display format should be 4 digits. (ex : 10 -> 0010) It must allow user to enter the values manually. It should not allow characters other than digits. It should not allow enter values having more than 3 digits. This is my current implementation :

JSpinner Number Display Format, The JSpinner shows the current number as an integer with a comma (i.e. 6,300). Is there an easy way to remove the comma from the JSpinners display? Hey, There's gotta be a way to do this: My JSpinner seems to like inserting commas in the numbers I enter when the number's big enough. Example: I enter "30000" and when I change the focus it makes it into "30,000".

Java number format Example, Also, we can use decimal point (.) to separate the decimal part or comma (,) in order to group numbers. Finally, ' sign is used to quote a prefix  public static class JSpinner.NumberEditor extends JSpinner.DefaultEditor An editor for a JSpinner whose model is a SpinnerNumberModel . The value of the editor is displayed with a JFormattedTextField whose format is defined by a NumberFormatter instance whose minimum and maximum properties are mapped to the SpinnerNumberModel .

Comments
  • +1 Allows more flexibility (if you're interested in something besides years; e.g., port number, etc.). Docs: docs.oracle.com/javase/7/docs/api/javax/swing/…
  • Your answer is no different than Brad's answer above.
  • -1 a) always use the most appropriate type (which is not Number here) b) no need to use a particular IDE
  • Always provide actual code help please, IDE-specific tools aren't an answer.