wicketstuff-spinner
wicketstuff-spinner integrates the spinner control from ken snyder (http://kendsnyder.com/sandbox/Spinner/demo.1.0.html) as a wicket behavior, which may be added to TextField objects (or it's subclasses).
wicketstuff-spinner is licensed under Apache Software License 2.0
Documentation
If you want basic spinning controls (-/+ buttons to the left and right of the textfield), just do:
myTextField.add(new Spinner());
with the result of something like this:
------------------- | - | 0 | + | -------------------
The -/+ buttons are generated automatically, but you can provide your own Components to be used as SpinButtons:
final Component downLabel; add(downLabel = new Label("down", "get down").setOutputMarkupId(true)); final Component upLabel; add(upLabel = new Label("up", "rise up").setOutputMarkupId(true)); myTextField.add(new Spinner() { @Override protected Component getSpinDownComponent() { return downLabel; } @Override protected Component getSpinUpComponent() { return upLabel; } });
The previous code results in the following ouput (assuming that the labels are placed to the left and the right of the input in the markup file):
-----------
get down | 0 | rise up
-----------
I admit, this is not the best excample, but you can still click the labels ("get down", "rise up") and the value in the textbox is de-/increased.
You can further customize the spinner (see Spinner#configure(Properties)) by setting the following properties:
interval The amount to increment round The number of decimal points to which to round min The lowest allowed value, false for no min max The highest allowed value, false for no max prefix String to prepend when updating suffix String to append when updating data An array giving a list of items through which to iterate onIncrement Function to call after incrementing onDecrement Function to call after decrementing afterUpdate Function to call after update of the value onStop Function to call on click or mouseup
Latest release
There is no release available yet, but you can check it out from the wicketstuff-minis SVN Repository
Project maintainers
Gerolf Seitz (gerolf.seitz at gmail dot com)
SVN
wicketstuff-spinner is part of wicketstuff-minis, the relevant source code can be found here.