| |

VerySource

 Forgot password?
 Register
Search
View: 645|Reply: 3

How to make numbers in jSpinner without ',' sign?

[Copy link]

1

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-2-23 06:30:03
| Show all posts |Read mode
When I jSpinner.setValue (int);
For example, int is 2016, and the effect he displays is "2,006"
How to remove the pesky ","?
Reply

Use magic Report

0

Threads

18

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-5-12 06:30:02
| Show all posts
JSpinner j = new JSpinner ();
    ((JSpinner.DefaultEditor) j.getEditor ()). GetTextField ().
        setFormatterFactory (new DefaultFormatterFactory (new NumberFormatter (new
        DecimalFormat ("#. #"))));
    j.setValue (new Integer (10000));
    JFrame f = new JFrame ();
    f.getContentPane (). add (j, BorderLayout.CENTER);
    f.setSize (100,100);
    f.setVisible (true);
Reply

Use magic Report

1

Threads

7

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-5-16 18:30:01
| Show all posts
Thank you, it's okay, but still have to join
import javax.swing.text. *;
import java.text.DecimalFormat;
Excuse me
What does new DecimalFormat ("#. #") mean?
Reply

Use magic Report

0

Threads

18

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-5-20 11:00:01
| Show all posts
new DecimalFormat ("#. #") is used to format numbers
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list