-
Notifications
You must be signed in to change notification settings - Fork 128
Spinner
Paweł Pastuszak edited this page Jun 26, 2016
·
4 revisions
This article applies to VisUI 1.0.2
Spinner (source) allows user to select number or object between specified values. User can change current object via buttons, mouse wheel and via entering it by keyboard.
Example usage:
//initial value: 10, min value: 5, max value: 20, step: 2
final IntSpinnerModel intModel = new IntSpinnerModel(10, 5, 20, 2);
Spinner intSpinner = new Spinner("int spinner", intModel);
intSpinner.addListener(new ChangeListener() {
@Override
public void changed (ChangeEvent event, Actor actor) {
System.out.println("changed int spinner to: " + intModel.getValue());
}
});
Floats using BigDecimal
:
new Spinner("float", new FloatSpinnerModel("1", "0", "10", "0.5", 2))
Float using SimpleFloatSpinnerModel
(where small number are used and high precision is not required):
new Spinner("simple float", new SimpleFloatSpinnerModel(10f, 5f, 20f, 1.5f, 1))
Custom object array:
Array<String> stringArray = new Array<String>();
stringArray.add("a");
stringArray.add("b");
stringArray.add("c");
stringArray.add("d");
stringArray.add("e");
final ArraySpinnerModel<String> arrayModel = new ArraySpinnerModel<String>(stringArray);
Spinner arraySpinner = new Spinner("array", arrayModel);
arraySpinner.addListener(new ChangeListener() {
@Override
public void changed (ChangeEvent event, Actor actor) {
System.out.println("changed array spinner to: " + arrayModel.getCurrent());
}
});
See README for VisUI introduction.