Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes jspinner design problem displaying length of a movie Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "jspinner design problem displaying length of a movie" Watch "jspinner design problem displaying length of a movie" New topic
Author

jspinner design problem displaying length of a movie

krillian konstatos
Ranch Hand

Joined: Jan 03, 2011
Posts: 49

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.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
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

Joined: Jan 03, 2011
Posts: 49

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 ...



Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

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.


[Jess in Action][AskingGoodQuestions]
krillian konstatos
Ranch Hand

Joined: Jan 03, 2011
Posts: 49

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 ...


Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2157
    
    7
The section from the Swing tutorial on How to Use Spinners shows you how to do this. Its create a CyclingSpinnerListModel.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jspinner design problem displaying length of a movie
 
Similar Threads
TimeZone conversion problem
Calculating download time
Unable to use JSpinner properly.
Threads with A GUI
TimeStamp.toString() does not work as expected