NumberBox control

Teknoloji

23 Sep 2009

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

Comment Form

Content In Different Language


Recent Comments


  • bohtein: I PREFER TO USE susE11.1 [...]
  • shaddamiv: So did it improve performance in any way? [...]
  • Chad: Hey, I had the same issues with JUnit. I have a test suite, and that calls all of my test cases w [...]
  • Nidal Basha: please send me the sdk [...]
  • Uday: Testing and development [...]
  • Our Scores