Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centering the Scene #1

Closed
Docter60 opened this issue Jul 7, 2017 · 1 comment
Closed

Centering the Scene #1

Docter60 opened this issue Jul 7, 2017 · 1 comment
Assignees
Projects

Comments

@Docter60
Copy link
Owner

Docter60 commented Jul 7, 2017

When shown, the scene seems to be positioned slightly above the center of the screen. The goal is to move the scene to the center of the screen at startup.

@Docter60 Docter60 added this to the Convert from Swing to JavaFX milestone Jul 7, 2017
@Docter60 Docter60 self-assigned this Jul 7, 2017
@Docter60
Copy link
Owner Author

Docter60 commented Jul 7, 2017

Centering a scene is made by doing this in the code:
Link to solution

public static final Rectangle2D SCREEN_BOUNDS = Screen.getPrimary().getVisualBounds();
public static final int STAGE_WIDTH = (int) SCREEN_BOUNDS.getWidth() / 2;
public static final int STAGE_HEIGHT = (int) SCREEN_BOUNDS.getHeight() / 2;

.
.
.

primaryStage.setX(STAGE_WIDTH / 2);
primaryStage.setY(STAGE_HEIGHT / 2);
Group root = new Group();
Scene scene = new Scene(root, STAGE_WIDTH, STAGE_HEIGHT, Color.BLACK);

primaryStage.show();

@Docter60 Docter60 closed this as completed Jul 7, 2017
@Docter60 Docter60 added this to Ideas in Roadmap Jul 7, 2017
@Docter60 Docter60 removed this from Ideas in Roadmap Jul 7, 2017
@Docter60 Docter60 added this to Backlog in Roadmap Jul 7, 2017
@Docter60 Docter60 moved this from Backlog to Completed in Roadmap Jul 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Roadmap
Completed
Development

No branches or pull requests

1 participant