0

How can I make a JSpinner that doesn't allow manual typing into it. I want my spinner to only have even numbers so I made it increment by twos. The the problem becomes that a user can type say a 3 and now your numbers are 3, 5, 7, 9 all of which are odd. I was hoping I was going to find a method such as setEditable() or setTypable() but didn't find one. Any ideas?

1 Answers1

2

Create a JSpinner that has a custom DefaultFormatter and a SpinnerModel to which the JSpinner does not listen. A complete example is seen here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045