Skip to content

Commit

Permalink
Removed the parent listener from Spacer control. No need to change co…
Browse files Browse the repository at this point in the history
…nstraints all the time.
  • Loading branch information
dlemmermann committed Aug 22, 2023
1 parent bcfe0bb commit 7678f5e
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions gemsfx/src/main/java/com/dlsc/gemsfx/Spacer.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,23 @@
*
* The active state of the Spacer can also be controlled through CSS with the
* "-fx-active" property.
*
*/
public class Spacer extends Region {

public Spacer() {
this(true);
}

public Spacer(boolean active) {
getStyleClass().add("spacer");

setActive(active);

managedProperty().bind(visibleProperty());
visibleProperty().bind(activeProperty());
parentProperty().addListener((observable, oldValue, newValue) -> {
if (newValue instanceof HBox) {
VBox.setVgrow(this, Priority.NEVER);
HBox.setHgrow(this, Priority.ALWAYS);
} else if (newValue instanceof VBox) {
VBox.setVgrow(this, Priority.ALWAYS);
HBox.setHgrow(this, Priority.NEVER);
} else {
VBox.setVgrow(this, Priority.NEVER);
HBox.setHgrow(this, Priority.NEVER);
}
});

VBox.setVgrow(this, Priority.ALWAYS);
HBox.setHgrow(this, Priority.ALWAYS);
}

private final BooleanProperty active = new StyleableBooleanProperty(false) {
Expand Down

0 comments on commit 7678f5e

Please sign in to comment.