Javafx 控制scenebuilder上自定义组件的多个属性

Javafx 控制scenebuilder上自定义组件的多个属性,javafx,custom-controls,scenebuilder,Javafx,Custom Controls,Scenebuilder,我在场景生成器上看不到自定义组件属性的旧值。 我想获得“速度单位类型”的旧值,以相应地更改最小/最大值 也许我可以使用静态最小/最大值并将其绑定到“速度单位类型”。但只是想知道是否有可能在SB上使用旧的设计tima值 public static enum SpeedUnitType {KILO_METERS_PER_HOUR,METERS_PER_SECOND,DATA_MILES_PER_HOUR} public static final int SPEED_MAX_DEFAULT_VALU

我在场景生成器上看不到自定义组件属性的旧值。 我想获得“速度单位类型”的旧值,以相应地更改最小/最大值

也许我可以使用静态最小/最大值并将其绑定到“速度单位类型”。但只是想知道是否有可能在SB上使用旧的设计tima值

public static enum SpeedUnitType {KILO_METERS_PER_HOUR,METERS_PER_SECOND,DATA_MILES_PER_HOUR}

public static final int SPEED_MAX_DEFAULT_VALUE =  1000; 
public static final int SPEED_MAX_LIMIT_VALUE = 999;
public static final double SPEED_MIN_LIMIT_VALUE = -100;
private final IntegerProperty   minValue    = new SimpleIntegerProperty(0);
private final IntegerProperty   maxValue    = new SimpleIntegerProperty(Integer.MAX_VALUE);
private final IntegerProperty   value       = new SimpleIntegerProperty(0);

private SpeedUnitType                      _speedUnit = SpeedUnitType.KILO_METERS_PER_HOUR;     
private ObjectProperty<SpeedUnitType>       speedUnitTypeProperty  ;

public final SpeedUnitType getSpeedUnitType() {
    return null == speedUnitTypeProperty ? _speedUnit : speedUnitTypeProperty.get();
}

public final void setSpeedUnitType(final SpeedUnitType UNIT) {
    if (null == speedUnitTypeProperty) {
        _speedUnit = UNIT;
    } else {
        speedUnitTypeProperty.set(UNIT);
    }
}

public final ObjectProperty<SpeedUnitType> speedUnitTypeProperty() {
    if (null == speedUnitTypeProperty) {
        speedUnitTypeProperty = new SimpleObjectProperty<>(this, "speedUnitTypeProperty", _speedUnit);
    }
    return speedUnitTypeProperty;
}

public Speed() {
    this.construct();
}

public void setMinValue(int min){ this.minValue.set(min); }
public int getMinValue() { return this.minValue.get(); }
public IntegerProperty minValueProperty() { return this.minValue;}
public void setMaxValue(int max) { this.maxValue.set(max);}
public int getMaxValue(){ return this.maxValue.get();}
public IntegerProperty maxValueProperty() { return this.maxValue; }
public final int getValue() { return value.get(); }
public final void setValue(final int VALUE) { value.set(VALUE);}
public final IntegerProperty valueProperty() {return value;}

private void construct()
{       
    this.maxValueProperty().addListener((observable, oldValue, newValue) ->
    {
        try
        {
            System.out.println("maxValueProperty --> The value was changed from " + oldValue.toString() + " to " + newValue.toString());

        }
        catch (Exception e)
        {
            System.err.println("Exception: " + e.getLocalizedMessage());
            setText("ERROR");
        }
    });

    speedUnitTypeProperty().addListener((observable, oldValue, newValue) -> {
        this.convertSpeedUnit(oldValue, newValue);
    });

    // this.maxValueProperty().bind(Bindings.add(10, this.minValueProperty())); test to bind property min to property max


}

请编辑您的问题,并完成问题的复制步骤以及有关您环境的信息(SceneBuilder版本)。您是否遵循了?嗨,我在向SB中添加自定义组件方面没有问题。我的环境:产品版本:JavaFX Scene Builder 2.u Java 1.8.0_25-b18,Oracle公司操作系统:Windows 8.1,amd64,6.3我正试图组织一个示例代码,在这里提供。简言之,尽管SB在演示应用程序中工作,但我无法看到我的自定义组件的属性的旧值。
public void convertSpeedUnit(SpeedUnitType oldValue, SpeedUnitType newValue)
{   
    if (oldValue == null)
        return;
    if (oldValue == newValue){}
    else{
        switch (oldValue){

        case KILO_METERS_PER_HOUR:
            System.out.println("convertSpeedUnit::formerUnit - KILO_METERS_PER_HOUR");
            switch (newValue){
            case METERS_PER_SECOND:
                System.out.println("convertSpeedUnit::currentUnit - METERS_PER_SECOND");
                setMinValue(10);
                setMaxValue(20);
                break;
            case DATA_MILES_PER_HOUR:
                System.out.println("convertSpeedUnit::currentUnit - DATA_MILES_PER_HOUR");
                setMinValue(11);
                setMaxValue(21);
                break; 
            }
            break;
        case METERS_PER_SECOND:
            System.out.println("convertSpeedUnit::formerUnit - METERS_PER_SECOND");
            switch (newValue){
            case KILO_METERS_PER_HOUR:
                System.out.println("convertSpeedUnit::currentUnit - KILO_METERS_PER_HOUR");
                setMinValue(12);
                setMaxValue(22);
                break;
            case DATA_MILES_PER_HOUR:
                System.out.println("convertSpeedUnit::currentUnit - DATA_MILES_PER_HOUR");
                setMinValue(13);
                setMaxValue(23);
                break;
            }
            break;  
        case DATA_MILES_PER_HOUR:
            System.out.println("convertSpeedUnit::formerUnit - DATA_MILES_PER_HOUR");
            switch (newValue){
            case KILO_METERS_PER_HOUR:
                System.out.println("convertSpeedUnit::currentUnit - KILO_METERS_PER_HOUR");
                setMinValue(34);
                setMaxValue(45);
                break;
            case METERS_PER_SECOND:
                System.out.println("convertSpeedUnit::currentUnit - METERS_PER_SECOND");
                setMinValue(56);
                setMaxValue(67);
                break;
            }
            break;
        } 
    } 
}