• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSpinner DateModel : Set a date

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
how is it possible to set a GregorianCalendar in a JSpinner or JSpinnerDateModel?
thanks
 
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
here is how I did it:
(the spinner shows only the year: 'yyyy').

cheers
Chantal
 
leliel
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
thanks for your reply.
I've done it this way:

My only problem now are the values, added by the ValueUp and ValueDown button.
I want to increase by 15 Minutes on ValueUp button click, vice versa decrease by 15 Minutes on ValueDown.
What kind of listener do I have to add? Without listener, the value is in-/decreased by one hour.
thanks
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I would not use listeners for implementing data logic. do that inside the SpinnerModel. you will have to extend the SpinnerDateModel. overwrite the methods getNextValue() and getPreviousValue() to return the time in 15 minutes steps.
Chantal
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
to be more specific:

as these methods are called quite often it seems quite an overhead to create Calendar objects inside of them.
a (faster) way (but not as "nice"):
- add th 15 minutes as milliseconds to the date value:

or:
reimplement the whole SpinnerDateModel based on GregorianCalendar, not Date.
cheers
Chantal
 
leliel
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks! all works fine.
 
reply
    Bookmark Topic Watch Topic
  • New Topic