Skip to content

Commit 13b3d98

Browse files
committed
First working attempt to use properties to update the warning background colour label.
1 parent cc756eb commit 13b3d98

2 files changed

Lines changed: 24 additions & 16 deletions

File tree

src/fjwright/runreduce/FontColorsDialog.fxml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,15 @@
5353
</Label>
5454
<Label fx:id="warningLabel" style="-fx-label-padding: 2;" text="Warning" GridPane.columnIndex="0"
5555
GridPane.rowIndex="6"/>
56-
<ColorPicker fx:id="warningColorPicker" onAction="#warningColourAction" GridPane.columnIndex="1"
57-
GridPane.rowIndex="6">
56+
<ColorPicker fx:id="warningColorPicker" GridPane.columnIndex="1" GridPane.rowIndex="6">
5857
<tooltip>
5958
<Tooltip fx:id="backgroundTooltip"
6059
text="Background colours are partially transparent by default.&#10;Click on Custom Color... to change the opacity."/>
6160
</tooltip>
6261
</ColorPicker>
6362
<Label fx:id="errorLabel" style="-fx-label-padding: 2;" text="Error" GridPane.columnIndex="0"
6463
GridPane.rowIndex="7"/>
65-
<ColorPicker fx:id="errorColorPicker" onAction="#errorColourAction" GridPane.columnIndex="1"
66-
GridPane.rowIndex="7">
64+
<ColorPicker fx:id="errorColorPicker" GridPane.columnIndex="1" GridPane.rowIndex="7">
6765
<tooltip>
6866
<fx:reference source="backgroundTooltip"/>
6967
</tooltip>

src/fjwright/runreduce/FontColorsDialog.java

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package fjwright.runreduce;
22

3+
import javafx.beans.binding.ObjectBinding;
4+
import javafx.beans.property.ObjectProperty;
35
import javafx.event.ActionEvent;
46
import javafx.fxml.FXML;
57
import javafx.scene.Node;
@@ -18,30 +20,38 @@ public class FontColorsDialog {
1820
private ColorPicker algebraicInputColorPicker, symbolicInputColorPicker,
1921
algebraicOutputColorPicker, symbolicOutputColorPicker, warningColorPicker, errorColorPicker;
2022

23+
private ObjectProperty<Color> warningColorPickerValueProperty;
24+
private ObjectBinding<Background> warningLabelBackgroundBinding;
25+
2126
@FXML
2227
private void initialize() {
2328
algebraicInputLabel.textFillProperty().bind(algebraicInputColorPicker.valueProperty());
2429
symbolicInputLabel.textFillProperty().bind(symbolicInputColorPicker.valueProperty());
2530
algebraicOutputLabel.textFillProperty().bind(algebraicOutputColorPicker.valueProperty());
2631
symbolicOutputLabel.textFillProperty().bind(symbolicOutputColorPicker.valueProperty());
32+
warningColorPickerValueProperty = warningColorPicker.valueProperty();
33+
warningLabelBackgroundBinding = new ObjectBinding<>() {
34+
{
35+
super.bind(warningColorPickerValueProperty);
36+
}
37+
38+
@Override
39+
protected Background computeValue() {
40+
return new Background(
41+
new BackgroundFill(warningColorPickerValueProperty.get(), null, null));
42+
}
43+
};
44+
warningLabel.backgroundProperty().bind(warningLabelBackgroundBinding);
2745

2846
algebraicInputColorPicker.setValue(Color.web(FontColors.algebraicInput));
2947
symbolicInputColorPicker.setValue(Color.web(FontColors.symbolicInput));
3048
algebraicOutputColorPicker.setValue(Color.web(FontColors.algebraicOutput));
3149
symbolicOutputColorPicker.setValue(Color.web(FontColors.symbolicOutput));
50+
warningColorPicker.setValue(Color.web(FontColors.warning));
51+
errorColorPicker.setValue(Color.web(FontColors.error));
3252

33-
Color color = Color.web(FontColors.warning);
34-
warningLabel.setBackground(new Background(new BackgroundFill(color, null, null)));
35-
warningColorPicker.setValue(color);
36-
color = Color.web(FontColors.error);
37-
errorLabel.setBackground(new Background(new BackgroundFill(color, null, null)));
38-
errorColorPicker.setValue(color);
39-
}
40-
41-
public void warningColourAction(ActionEvent actionEvent) {
42-
}
43-
44-
public void errorColourAction(ActionEvent actionEvent) {
53+
// warningLabel.setBackground(new Background(new BackgroundFill(color, null, null)));
54+
// errorLabel.setBackground(new Background(new BackgroundFill(color, null, null)));
4555
}
4656

4757
/**

0 commit comments

Comments
 (0)