• 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

Movie-like timeline with JSlider

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear all,

The code below is an example of how I want to include a movie-like timeline component in my application.
I thought the easiest would be to make use of a JSlider. But somehow, I need to adjust the maximum/minimum
of the JSlider when the user is dragging the handle. I tried to simplify this a little bit, by only changing the
minimum/maximum when the user drags the knob to the min or max.

However, the way I make use of the ChangeListener now results in a StackOverflow. The single System.out.prinln
statement I've included shows that the current value grows along with the maximum value, even though I've tried
to reset it after the maximum is increased.

Does somebody know how to fix this?
Thanks!

 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The changing of the minimum and maximum fire a stateChanged event as well. Therefore, in your event listener you should keep track of whether or not you're already handling an event. I usually do this using a boolean:
However, I don't really get why you need to change your minimum and maximum. In videos on Youtube etc, the minimum and maximum of a movie usually stay the same - the minimum at 00:00 and the maximum at the movie's end.
 
John Sutt
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perfect! That works fine.

I understand your remark about Youtube and others, but in my case, I want it like this because I want the
user to be able to position the movie at a fraction of a second, which is not normally required.
So if a movie takes longer than 5 minutes, I would have lost some precision. Now maybe I can get the
minimum/maximum to change even while dragging the knob. And if I can tune that nicely, this will
be exactly what I want.

Thank you.
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
 
reply
    Bookmark Topic Watch Topic
  • New Topic