I'm programming a javafx application, and I'd like to keep my window from going outside the screen bounds, since there isn't much use for this. So, for example, the window shouldn't be able to be dragged so that half of it is off the screen.
public class ui extends Application{
public static void main (String[] args){
launch(args);
}
public void start(Stage mainStage){
mainStage.initStyle(StageStyle.DECORATED);
Rectangle2D mainScreen = Screen.getPrimary().getVisualBounds();
mainStage.setWidth(mainScreen.getWidth());
mainStage.setHeight(mainScreen.getHeight());
BorderPane mainPane = new BorderPane(background);
Scene mainScene = new Scene(mainPane, Color.BLACK);
mainStage.setScene(mainScene);
mainStage.show();
}
}