i am bit new to java and swing so... can someone please tell me how to utilize swing textfield component for number processing (money, decimal...) ? or can someone tell me where to find swing component witch is designed for this ? I am 开发者_StackOverflow中文版building a small ERP app, and standard Swing or SwingX simple do not have a good number processing component)
(FormattedTextField is no good!)
JSpinner is designed for numbers. But what kind of number processing do you need from the component?
I've implemented number fields based on JFormattedTextField.
They also support a min and a max value.
Maybe you find them useful (the library is open source):
http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JRealNumberField.html
http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JDoubleField.html
http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JFloatField.html
http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JLocalizedRealNumberField.html
http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JLocalizedDoubleField.html
http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JLocalizedFloatField.html
http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JWholeNumberField.html
http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JByteField.html
http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JIntegerField.html
http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JLongField.html
http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JShortField.html
Homepage:
http://www.softsmithy.org
Download:
http://sourceforge.net/project/showfiles.php?group_id=64833
Tutorial: http://softsmithy.sourceforge.net/lib/docs/tutorial/swing/number/index.html
-Puce
You can keep a listener to check the content being entered and validate accordingly..
Here is an example
精彩评论