Add basic property binding test
This commit is contained in:
parent
aa42155644
commit
47e0ad7393
@ -21,7 +21,7 @@
|
||||
<FlowPane alignment="CENTER_LEFT" prefHeight="41.0" prefWidth="640.0">
|
||||
<children>
|
||||
<Label prefHeight="17.0" prefWidth="49.0" text="Station: " />
|
||||
<TextField editable="false" style="-fx-background-color: #EEEEEE; -fx-border-color: #AAAAAA;" text="My Station">
|
||||
<TextField fx:id="stationNameField" editable="false" style="-fx-background-color: #EEEEEE; -fx-border-color: #AAAAAA;" text="My Station">
|
||||
<FlowPane.margin>
|
||||
<Insets right="10.0" />
|
||||
</FlowPane.margin>
|
||||
@ -75,7 +75,7 @@
|
||||
</font>
|
||||
</Label>
|
||||
<Label layoutX="170.0" layoutY="16.0" text="Numbers station address:" />
|
||||
<TextField layoutX="180.0" layoutY="40.0" prefHeight="25.0" prefWidth="390.0" AnchorPane.leftAnchor="188.0" AnchorPane.rightAnchor="0.0" />
|
||||
<TextField fx:id="stationAddressField" layoutX="180.0" layoutY="40.0" prefHeight="25.0" prefWidth="390.0" AnchorPane.leftAnchor="188.0" AnchorPane.rightAnchor="0.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<Separator prefWidth="200.0" />
|
||||
|
@ -5,11 +5,20 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TextField;
|
||||
|
||||
public class NumbersStationSettingsController {
|
||||
private NumbersStationSettings settings;
|
||||
private StringProperty stationNameAndAddress = new SimpleStringProperty();
|
||||
|
||||
@FXML
|
||||
private TextField stationNameField;
|
||||
|
||||
@FXML
|
||||
private TextField stationAddressField;
|
||||
|
||||
public NumbersStationSettingsController() throws IOException {
|
||||
System.out.println("Created settings controller");
|
||||
@ -20,9 +29,19 @@ public class NumbersStationSettingsController {
|
||||
settings.getStations().add(new StationSettings());
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void initialize() {
|
||||
stationNameField.textProperty().bindBidirectional(stationNameAndAddress);
|
||||
stationAddressField.textProperty().bindBidirectional(stationNameAndAddress);
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void handleSaveButtonPress() throws IOException {
|
||||
XmlMapper xmlMapper = new XmlMapper();
|
||||
xmlMapper.writeValue(new File("setting-test.xml"), settings);
|
||||
}
|
||||
|
||||
public StringProperty stationNameAndAddressProperty() {
|
||||
return stationNameAndAddress;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user