center of tech


It is not so difficult to create a NumberBox control using the Textbox contorl, triggers and data binding:
import javafx.scene.*;
import javafx.scene.control.*;
public class NumberBox extends CustomNode {
public var value:Number on replace { str = "{value}"};
var str:String on replace{
try{
value = Number.valueOf(str);
} catch(e){
str = "0";
}
}
public override function create(): Node {
TextBox {
columns: 12
selectOnFocus: true
text: bind str with inverse
}
}
}
Example with the NumberBox control:
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.scene.control.*;
var num = 10.0;
Stage {
title: "NumberBox"
width: 250
height: 280
scene: Scene {
content: VBox{
translateX: 20
translateY: 20
content: [
Slider {
min: 0
max: 100
value: bind num with inverse
}
NumberBox{
value: bind num with inverse
}
]
}
}
}
Source/Kaynak : http://blogs.sun.com/alexsch/entry/numberbox_control