0
我有TableView
的Roads
,列Name
和列Number of Lanes
。 Number of Lanes
顯示一個整數,即一條道路的車道數。當添加一條新道路時,我有另一個TableView
設置車道的屬性。我Lane
類是:JavaFX:將TableView列綁定到另一個TableView的行數
public class Lane {
private StringProperty name;
private FloatProperty width;
private BooleanProperty normalDirection;
public Lane(String name, float width, boolean normalDirection) {
this.name = new SimpleStringProperty(name);
this.width = new SimpleFloatProperty(width);
this.normalDirection = new SimpleBooleanProperty(normalDirection);
}
public void setName(String value) {
nameProperty().set(value);
}
public String getName() {
return nameProperty().get();
}
public StringProperty nameProperty() {
if (name == null) {
name = new SimpleStringProperty(this, "name");
}
return name;
}
public void setWidth(float value) {
widthProperty().set(value);
}
public float getWidth() {
return widthProperty().get();
}
public FloatProperty widthProperty() {
if (width == null) {
width = new SimpleFloatProperty(this, "width");
}
return width;
}
public void setNormalDirection(boolean value) {
normalDirectionProperty().set(value);
}
public boolean getNormalDirection() {
return normalDirectionProperty().get();
}
public BooleanProperty normalDirectionProperty() {
if (normalDirection == null) normalDirection = new SimpleBooleanProperty(this, "normalDirection");
return normalDirection;
}
}
我試圖創建一個類Road
,我想一個屬性private IntegerProperty numberOfLanes
綁定在車道TableView
使用的ObservableList<Lane>
的大小,但我不知道什麼是最好的方式來做到這一點。
我是JavaFX
世界的新手和任何幫助表示讚賞。先謝謝了。
它的工作原理。謝謝! – Giorgio