So here is the solution. Fisrt of all create a java class file & and name it.
Here I am giving the name formDecorator.java
package customform;
import java.awt.Insets;
import javafx.scene.Node;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
public class formDecorator extends AnchorPane
{
private double xOffset = 0;
private double yOffset = 0;
private Stage primaryStage;
public formDecorator(Stage stage, Node node) {
super();
primaryStage = stage;
this.setPadding(new javafx.geometry.Insets(0, 0, 0, 0));
this.getChildren().addAll(node);
this.setOnMousePressed((MouseEvent event) -> {
xOffset = event.getSceneX();
yOffset = event.getSceneY();
});
this.setOnMouseDragged((MouseEvent event) -> {
primaryStage.setX(event.getScreenX() - xOffset);
primaryStage.setY(event.getScreenY() - yOffset);
});
}
}
and Second File is your main class file. Mine is custorForm. There you have to write the below code -
package customform;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class CustomForm extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
stage.initStyle(StageStyle.TRANSPARENT);
Scene scene = new Scene(new formDecorator(stage,root));
scene.setFill(null);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Thats it.. Now run your program.