Created
April 19, 2017 05:56
-
-
Save omernaci/94c767e519139464edc7a8092cabd415 to your computer and use it in GitHub Desktop.
JavaFX Scene Size with Screen Resolution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.Dimension; | |
import javafx.application.Application; | |
import javafx.scene.Scene; | |
import javafx.scene.layout.AnchorPane; | |
import javafx.stage.Stage; | |
public class ScreenResolutionDemo extends Application { | |
@Override | |
public void start(Stage primaryStage) throws Exception { | |
Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); | |
double width = screenSize.getWidth() / 3; | |
double height = screenSize.getHeight() / 2; | |
try { | |
primaryStage.setScene(new Scene(new AnchorPane(), width, height)); | |
primaryStage.show(); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
public static void main(String[] args) { | |
launch(args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment