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


  • Jim Dougherty: You can fix Solaris 8 named_to_major, path_to_inst, drivers_alias errors on boot by simply installin [...]
  • psha: doesn't work [...]
  • Jiji joseph: Can you please let me know how can I get the SRMTools ? [...]
  • Sebastian: Hi, I don't think using a suite will work either. The order is also random. It is just a coincide [...]
  • Henry: Hey, I can't seem to get this working on my mac. The page down works if I put the focus on the wind [...]
  • Our Scores