Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

8
Animating a JSlider (Java Swing)
Post Body

Hey, I'm working on an interactive map project for a software engineering class. Our code is broken down into a control panel and the actual map. To progress through the years covered by our data, we're using a JSlider as a timeline. I've been trying to implement a 'play' button that when clicked steps through each year, but what I'm trying isn't working.

Inside the Button's actionPerformed() I call a play/pause method which animates the timeline like so: while(timeline.getValue() < timeline.getMaximum()){ timeline.setValue(timeline.getValue() 5); //jumps 5 years timeline.repaint(); try { Thread.sleep(1000); } catch(InterruptedException e) { e.printStackTrace(); } }

The problem is that this process runs for a couple seconds (while the sleeps execute) and then pop, the slider's at the end of the timeline. It seems like the repaint() there isn't getting called at all. I've tried something with run() and SwingUtilities.invokeLater() that I saw somewhere else, but with the same results. Help?

Author
Account Strength
100%
Account Age
13 years
Verified Email
Yes
Verified Flair
No
Total Karma
17,674
Link Karma
2,256
Comment Karma
15,383
Profile updated: 18 hours ago
Posts updated: 2 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
13 years ago