У меня есть TableView
из Roads
со столбцом Name
и столбцом Number of Lanes
. Number of Lanes
показывают целое число, обозначающее количество полос на дороге. Когда я добавляю новую дорогу, у меня есть еще один TableView
, где задаются свойства полосы. Мой Lane
класс:
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
с размером ObservableList<Lane>
, используемого в TableView
полосах, но я не знаю, как лучше всего это сделать.
Я новичок в мире JavaFX
, и любая помощь приветствуется. Заранее спасибо.