-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
P4
-
Affects Version/s: jfx25
-
Component/s: javafx
-
None
The documentation of Stage.fullScreen states:
* However once in full-screen mode, {@code Stage}'s {@code x}, {@code y},
* {@code width}, and {@code height} variables will continue to represent
* the non-full-screen position and size of the window; the same for
* {@code iconified}, {@code resizable}, {@code style}, and {@code
* opacity}. If changes are made to any of these attributes while in
* full-screen mode, upon exiting full-screen mode the {@code Stage} will
* assume those attributes.
This does not correspond to the actual behavior of a Stage, where x, y, width, and height will correspond to the actual position and size of a full-screen window (at least on Windows, haven't tested other platforms). Here's a test application:
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class FullScreenTest extends Application {
@Override
public void start(Stage stage) throws Exception {
var fullScreenButton = new Button("Toggle fullscreen");
fullScreenButton.setOnAction(_ -> stage.setFullScreen(!stage.isFullScreen()));
var setSize1Button = new Button("Set size = 400x200");
setSize1Button.setOnAction(_ -> {
stage.setWidth(400);
stage.setHeight(200);
});
var setSize2Button = new Button("Set size = 800x400");
setSize2Button.setOnAction(_ -> {
stage.setWidth(800);
stage.setHeight(400);
});
var positionLabel = new Label();
positionLabel.textProperty().bind(Bindings.createStringBinding(
() -> String.format("Stage position: %.0f, %.0f", stage.getX(), stage.getY()),
stage.xProperty(), stage.yProperty()));
var sizeLabel = new Label();
sizeLabel.textProperty().bind(Bindings.createStringBinding(
() -> String.format("Stage size: %.0f x %.0f", stage.getWidth(), stage.getHeight()),
stage.widthProperty(), stage.heightProperty()));
var root = new VBox(fullScreenButton, setSize1Button, setSize2Button, positionLabel, sizeLabel);
stage.setScene(new javafx.scene.Scene(root));
stage.setWidth(400);
stage.setHeight(200);
stage.show();
}
}
* However once in full-screen mode, {@code Stage}'s {@code x}, {@code y},
* {@code width}, and {@code height} variables will continue to represent
* the non-full-screen position and size of the window; the same for
* {@code iconified}, {@code resizable}, {@code style}, and {@code
* opacity}. If changes are made to any of these attributes while in
* full-screen mode, upon exiting full-screen mode the {@code Stage} will
* assume those attributes.
This does not correspond to the actual behavior of a Stage, where x, y, width, and height will correspond to the actual position and size of a full-screen window (at least on Windows, haven't tested other platforms). Here's a test application:
import javafx.application.Application;
import javafx.beans.binding.Bindings;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class FullScreenTest extends Application {
@Override
public void start(Stage stage) throws Exception {
var fullScreenButton = new Button("Toggle fullscreen");
fullScreenButton.setOnAction(_ -> stage.setFullScreen(!stage.isFullScreen()));
var setSize1Button = new Button("Set size = 400x200");
setSize1Button.setOnAction(_ -> {
stage.setWidth(400);
stage.setHeight(200);
});
var setSize2Button = new Button("Set size = 800x400");
setSize2Button.setOnAction(_ -> {
stage.setWidth(800);
stage.setHeight(400);
});
var positionLabel = new Label();
positionLabel.textProperty().bind(Bindings.createStringBinding(
() -> String.format("Stage position: %.0f, %.0f", stage.getX(), stage.getY()),
stage.xProperty(), stage.yProperty()));
var sizeLabel = new Label();
sizeLabel.textProperty().bind(Bindings.createStringBinding(
() -> String.format("Stage size: %.0f x %.0f", stage.getWidth(), stage.getHeight()),
stage.widthProperty(), stage.heightProperty()));
var root = new VBox(fullScreenButton, setSize1Button, setSize2Button, positionLabel, sizeLabel);
stage.setScene(new javafx.scene.Scene(root));
stage.setWidth(400);
stage.setHeight(200);
stage.show();
}
}