This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

mbread presents ...



This is a slider to allow the user to select a number

Use the buttons to test each of them methods available on the slider (which would normally be called in the code of the scenario using the slider.)

The user can select a value between zero and the maximum value (inclusive).
The selected value can be displayed next to the slider as a number or a percentage, or hidden.
You can set sectons to be marked on the slider.

To use the slider in your own project, create an Actor class called 'Slider', download the source code for this demo, and replace all the code in your Slider class with the entire contents of the Slider class from this demo.

Note: if the speed is decreased in Greenfoot, then the slider will not move smoothly, but only update on each execution of act. Also, if the size of the cells specified when the world is created is greater than one pixel then the slider will only be able to move in increments equal to the size of the cells.

For an example of the slider in use, see my 'WarBugs' game.

9832 views / 12 in the last 7 days

2 votes | 0 in the last 7 days

Tags: mouse demo with-source slider numerical input numbers percentage gui

This scenario is a member of: Reusable actors & support classes

open in greenfoot
Your browser does not support the canvas tag.
A new version of this scenario was uploaded on Sat Feb 14 15:33:23 UTC 2009

Want to leave a comment? You must first log in.

Who likes this?

Game/maniac ThatOneGuy