• 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:

jspinner design problem displaying length of a movie

 
Ranch Hand
Posts: 49
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello, erveryone!

this is my first post here. my english grammar is not that well but i like to think that someone will understand what
i am trying to say. there is never a universal translator around when you need one. anyway here is my problem.

i am having a problem with the design of a class that is extending a jpanel component. in it i have a jspinner
and a jbutton object to right of the former component. the purpose of the class is to let the user type in the length of
a movie. the class in question is part of a movie db app. when the user clicks the jbutton a joptionpane showinputdialog
is displaying a dialog with a jcombobox that handles the selection of options asking how the user wishes the app to display
the runtime of the movie either as in the format of number of minutes, hours + mintes or minutes + hours + seconds. this
may sound a bit # unnecessarily complicated to someone else but i have never seen this option in another movie db app.
i have tried this using the jspinner's data models like the spinnernumbermodel, spinnerdatemodel classes and the
jspinner's editor classes like the DateEditor and NumberEditor. its rather easy to work with the date and calendar classes
when you have to display the current time, manipulate time using the set method in the Calendar class. but i am facing a
lot of trouble when i need to increment the time displayed in a jspinner when its set to 0 hours and 0 minutes as the default
value.

all in all i want to increment the minute value untill it displays 59 seconds and when this reaches 60 i want the hour value
to follow in a manner similar as when you are setting a clock on your living room wall or a rolex for that matter.
maybe i am having to much demands on my own behalf in achieving this time setting design. it can emagine that it would
easier done having three textfield placed next to each other in which the user would fill out the current length of the movie.
my programming knowledges are somewhat limited so i could use a lot of tips on other solutions to my problem. i will post
some code later so far i mostly need some tips to other solutions, or feedback, or links to similiar time manipulating
problems that i have involving spinners and setting the length of a movie or something. anyway i hope i am not totally
out there in the blue.
 
Marshal
Posts: 80960
525
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Can you work out hours minutes and seconds from an input which is seconds only? Can you take 12345 seconds and get 3 hours 25 minutes 45 seconds from it? Can you increment a counter with the % operator?
 
krillian konstatos
Ranch Hand
Posts: 49
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Welcome to the Ranch

Can you work out hours minutes and seconds from an input which is seconds only? Can you take 12345 seconds and get 3 hours 25 minutes 45 seconds from it? Can you increment a counter with the % operator?



Hi! In cyberspace everyone can here you scream

Anyway im not that sure what you are trying to say but i take it that you are trying to pitch me in some direction i have not yet discovered or maybe i am not that good in communicating in english.
I have written a small example of a spinner that displays the current time in the format hours, minutes and seconds using the SpinnerDateModel and the SimpleDateFormat classes. This is rather trivial to do
but i wish i could set the time as input values in some way ... maybe im not thinking correctly or not at all but only time will tell i hope ...



 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can write your own implementation of SpinnerModel, and your own subclass of JSpinner.DefaultEditor -- you're not constrained to use only the ones that are supplied by the JDK. I think in this case you probably need to write your own editor subclass.
 
krillian konstatos
Ranch Hand
Posts: 49
Netbeans IDE PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ernest Friedman-Hill wrote:You can write your own implementation of SpinnerModel, and your own subclass of JSpinner.DefaultEditor -- you're not constrained to use only the ones that are supplied by the JDK. I think in this case you probably need to write your own editor subclass.



Hi! very thanks for the reply and the kind hint!

I have thought on doing something similar to this but at the moment i haven't got any working code samples yet.
I am planning to do something like that using the following basic approach it just for letting someone see if i am
in the right direction or not ...


 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The section from the Swing tutorial on How to Use Spinners shows you how to do this. Its create a CyclingSpinnerListModel.
 
I am a man of mystery. Mostly because of 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