• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Trap up/down arrowbutton event in JSpinner

 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Of course, I found a very beautiful couch. Definitely. And this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic