From 124df8489b22c834796f0e58a20bc59d1ebfcc9a Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 19 Dec 2017 15:47:33 +0100 Subject: [PATCH 1/2] Now CONTAINER resizes automatically to ScrollPane bounds --- .../css/user/ContainerScrollStyleSheet.java | 22 +++++++++++++++++++ fxml/model.fxml | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Classes/css/user/ContainerScrollStyleSheet.java b/Classes/css/user/ContainerScrollStyleSheet.java index f47f265..17e6d9e 100644 --- a/Classes/css/user/ContainerScrollStyleSheet.java +++ b/Classes/css/user/ContainerScrollStyleSheet.java @@ -2,11 +2,17 @@ package Classes.css.user; import Classes.css.core.Context; import Classes.css.core.Ruleset; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.geometry.Bounds; import javafx.scene.Node; +import javafx.scene.control.ScrollPane; +import javafx.scene.layout.FlowPane; public class ContainerScrollStyleSheet{ /* Builds all necessary CSS/layout rules */ + @SuppressWarnings({ "unchecked", "rawtypes" }) public ContainerScrollStyleSheet(Node target) throws Exception{ /* (1) Set rules */ @@ -16,6 +22,22 @@ public class ContainerScrollStyleSheet{ .add("right", 0) // .add("pref-height", ) .apply(); + + /* (2) Manage dynamic 1st children bounds to it */ + ScrollPane spane = (ScrollPane) target; + + spane.layoutBoundsProperty().addListener(new ChangeListener(){ + + @Override + public void changed(ObservableValue observable, Object oldValue, Object newValue) { + System.out.println(spane.getLayoutBounds().getWidth()); + FlowPane child = (FlowPane) spane.getContent(); + child.setPrefWidth( spane.getLayoutBounds().getWidth() ); + child.setPrefHeight( spane.getLayoutBounds().getHeight() ); + + } + }); + } } diff --git a/fxml/model.fxml b/fxml/model.fxml index 1315751..1f8381b 100644 --- a/fxml/model.fxml +++ b/fxml/model.fxml @@ -312,7 +312,7 @@ - + From ae3a0657902efbec7922e297a413d50f36fdafeb Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 19 Dec 2017 16:29:19 +0100 Subject: [PATCH 2/2] Created vocabulary template in fxml.vocabulary_disp --- .../css/user/ContainerScrollStyleSheet.java | 1 - fxml/model.fxml | 85 ++++++++----------- fxml/vocabulary_disp.fxml | 70 +++++++++++++++ 3 files changed, 106 insertions(+), 50 deletions(-) create mode 100644 fxml/vocabulary_disp.fxml diff --git a/Classes/css/user/ContainerScrollStyleSheet.java b/Classes/css/user/ContainerScrollStyleSheet.java index 17e6d9e..551af47 100644 --- a/Classes/css/user/ContainerScrollStyleSheet.java +++ b/Classes/css/user/ContainerScrollStyleSheet.java @@ -12,7 +12,6 @@ import javafx.scene.layout.FlowPane; public class ContainerScrollStyleSheet{ /* Builds all necessary CSS/layout rules */ - @SuppressWarnings({ "unchecked", "rawtypes" }) public ContainerScrollStyleSheet(Node target) throws Exception{ /* (1) Set rules */ diff --git a/fxml/model.fxml b/fxml/model.fxml index 1f8381b..8174cba 100644 --- a/fxml/model.fxml +++ b/fxml/model.fxml @@ -2,13 +2,13 @@ + - @@ -314,58 +314,45 @@ - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +