Skip to content

Commit

Permalink
Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kentros Alexandros authored and Kentros Alexandros committed Apr 30, 2019
1 parent 0a1eb83 commit 04cea9b
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -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.
* <p>
* Usage:
*
* <pre>
* {
* &#64;code
* //add the code here
* }
* </pre>
*
* @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() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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();
Expand Down Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 04cea9b

Please sign in to comment.