Archive for the tag 'NumericStepper'

Create a AsWing’s NumericStepper

November 5th, 2008

Although we have JAdjuster component for AsWing, steroids but sometimes people ask us for NumericStepper, viagra here most time, we tell them just use JAdjuster, we know it’s different, but most time they are replacable.

Well, if you do want a NumericStepper component, it’s easy to create by your self, just combine with JTextField+2Button, with a BoundedRangeModel, a basic MVC NumericStepper component born.

Here’s a example implementation, see the demo screenshot below:

The test App source code:


import flash.display.Sprite;

import org.aswing.*;

public class NumericStepperTest extends Sprite{

private var infoText:JTextArea;
private var ns:NumericStepper;

public function NumericStepperTest(){
var frame:JFrame = new JFrame(null, "NumericStepperTest");
var topPane:JPanel = new JPanel();
ns = new NumericStepper();
var button:JButton = new JButton("Reset");
topPane.appendAll(button, ns);

infoText = new JTextArea();
frame.getContentPane().append(topPane, BorderLayout.NORTH);
new JScrollPane(infoText), BorderLayout.CENTER);
frame.setSizeWH(300, 300);;


private function __resetValue(e:Event):void{

private function __nsStateChanged(e:Event):void{
infoText.appendByReplace("value : " + ns.getModel().getValue()+"

Well, for copyright reason, i can’t post all of the component codes, maybe after the book published, there will be a downloadable version.

But trust me, if you want, you can implement it easily by yourself, a Container with a BorderLayout, left is a JTextField(lost border and background), right is a Box contains two JButton with Arrow Icons, and with a BoundedRangeModel to hold the data(you can take JAdjuster as example), finally create a Border to your NumericStepper, it is!

  • A3 , Tutorials
  • Comments Off on Create a AsWing’s NumericStepper