• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Trap up/down arrowbutton event in JSpinner  RSS feed

 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends, sir, madam

I need to check whether the value entered in JSpinner is valid or not on click of up/down arrow button. So I need to trap the up/down arrow button click events.

Steps to be followed
1. User entered value in the JSpinner manually without using the up/down arrow keys.
2. If the user presses up/down key then I need to validate whether the value entered in JSpinner is valid or not. If not then I need to display some default value.

Is this possible ? Am I on the right track ?

Any help is highly appreciated.

Thanks and Regards
Rohit.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
set your own ui, extending BasicSpinnerUI
override createNextButton() and createPreviousButton()
add actionListeners to both buttons
in actionPerformed, get the textfield and setValue(spinner.getValue())

if valid, no changes
if invalid, previous valid value will be set
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!