diff --git a/src/main/java/com/goxr3plus/fxborderlessscene/borderless/BorderlessPane.java b/src/main/java/com/goxr3plus/fxborderlessscene/borderless/BorderlessPane.java new file mode 100644 index 0000000..c384cb4 --- /dev/null +++ b/src/main/java/com/goxr3plus/fxborderlessscene/borderless/BorderlessPane.java @@ -0,0 +1,58 @@ +/* + * + */ +package com.goxr3plus.fxborderlessscene.borderless; + +import java.io.IOException; + +import javafx.beans.property.BooleanProperty; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Node; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.Pane; +import javafx.stage.Stage; +import javafx.stage.StageStyle; + +/** + * Undecorated JavaFX Scene with implemented move, resize, minimize, maximize and Aero Snap. + *
+ * Usage: + * + *
+ * { + * @code + * //add the code here + * } + *+ * + * @author Nicolas Senet-Larson + * @author GOXR3PLUS STUDIO + * @version 1.0 + */ +public class BorderlessPane extends AnchorPane { + + + + public BorderlessPane () throws IOException { + + // ------------------------------------FXMLLOADER ---------------------------------------- + + FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/Borderless.fxml")); + loader.setController(this); + loader.setRoot(this); + loader.load(); + + } + + + /** + * Called as soon as .fxml is initialised + */ + @FXML + private void initialize() { + + } +} diff --git a/src/main/java/com/goxr3plus/fxborderlessscene/borderless/BorderlessScene.java b/src/main/java/com/goxr3plus/fxborderlessscene/borderless/BorderlessScene.java index cae52b6..122e150 100644 --- a/src/main/java/com/goxr3plus/fxborderlessscene/borderless/BorderlessScene.java +++ b/src/main/java/com/goxr3plus/fxborderlessscene/borderless/BorderlessScene.java @@ -37,18 +37,11 @@ public class BorderlessScene extends Scene { private BorderlessController controller; /** The root. */ - private AnchorPane root; + private BorderlessPane root; - /** The stage. */ + /** The Stage. */ private Stage stage; - public static BorderlessScene forUtility(Stage stage, Parent sceneRoot) { - BorderlessScene scene = new BorderlessScene(stage, StageStyle.UNDECORATED, sceneRoot); - scene.setSnapEnabled(false); - scene.setResizable(false); - return scene; - } - /** * The constructor. * @@ -59,23 +52,26 @@ public static BorderlessScene forUtility(Stage stage, Parent sceneRoot) { public BorderlessScene(Stage stage, StageStyle stageStyle, Parent sceneRoot) { super(new Pane()); try { - // Load the FXML - FXMLLoader loader = new FXMLLoader(); - loader.setLocation(getClass().getResource("/fxml/Borderless.fxml")); - this.root = loader.load(); + this.root = new BorderlessPane(); // Set Scene root setRoot(this.root); setContent(sceneRoot); // Initialize the Controller - this.controller = loader.getController(); + this.controller = new BorderlessController(); this.controller.setStage(stage); this.controller.createTransparentWindow(stage); // StageStyle stage.initStyle(stageStyle); + if (stageStyle == StageStyle.UTILITY) { + setSnapEnabled(false); + setResizable(false); + } + + // Stage this.stage = stage; } catch (IOException e) { e.printStackTrace(); @@ -107,10 +103,10 @@ public BorderlessScene(Stage stage, StageStyle stageStyle, Parent sceneRoot, dou public void setContent(Parent content) { this.root.getChildren().remove(0); this.root.getChildren().add(0, content); - AnchorPane.setLeftAnchor(content, Double.valueOf(0.0D)); - AnchorPane.setTopAnchor(content, Double.valueOf(0.0D)); - AnchorPane.setRightAnchor(content, Double.valueOf(0.0D)); - AnchorPane.setBottomAnchor(content, Double.valueOf(0.0D)); + AnchorPane.setLeftAnchor(content, 0.0D); + AnchorPane.setTopAnchor(content, 0.0D); + AnchorPane.setRightAnchor(content, 0.0D); + AnchorPane.setBottomAnchor(content, 0.0D); } /**