Create a numeric text box in java Swing with increment and decrement buttons

Viewed 20963

How can I create a numeric text box in java swing , which has two buttons (up and down) which increments and decrements the value in the text box respectively. Also this text box must be editable with ONLY NUMERIC VALUES. Something like this

Numeric Text Box

I tried by placing two buttons near a text box and manually doing the operation on button click.

My try Text Box

Is there any other method in which I can do this in a better way and achieve a similar result as the first image.

Thanks :)

2 Answers
Related