小编ori*_*ncs的帖子

javafx Bindings.createStringBinding 但绑定实际上不起作用

我想绑定textPropertyLabel对象的SimpleIntegerProperty有帮助的Bindings,但是当我改变它不会改变文本 SimpleIntegerProperty对象的实时。任何有关如何进行textProperty更改的帮助将不胜感激。

package sample;

import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.control.Slider;

import java.net.URL;
import java.util.ResourceBundle;

public class Controller implements Initializable
{

    @FXML
    private Slider slider;

    @FXML
    private Label label;

    @Override
    public void initialize(URL location, ResourceBundle resources) {

        MyObject object = new MyObject(0);

        label.textProperty().bind(Bindings.createStringBinding(() -> " hello " + object.numberProperty().get() * (10 + 12)/2));

        object.numberProperty().bind(slider.valueProperty());

    }
}


class MyObject {

    private SimpleIntegerProperty number;

    public Object(int …
Run Code Online (Sandbox Code Playgroud)

binding javafx

3
推荐指数
1
解决办法
2699
查看次数

标签 统计

binding ×1

javafx ×1