This example set the application run in full screen.
JavaFX application run in full screen |
package javafx_screen; import javafx.application.Application; import javafx.geometry.Rectangle2D; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.layout.StackPane; import javafx.stage.Screen; import javafx.stage.Stage; /** * * @web http://java-buddy.blogspot.com/ */ public class JavaFX_Screen extends Application { @Override public void start(Stage primaryStage) { Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds(); Label label = new Label(); label.setText( visualBounds.getWidth() + " x " + visualBounds.getHeight()); StackPane root = new StackPane(); root.getChildren().add(label); Scene scene = new Scene(root, visualBounds.getWidth(), visualBounds.getHeight()); primaryStage.setTitle("java-buddy.blogspot.com"); primaryStage.setScene(scene); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
Thanks for posting this! It makes my life so much easier. Was thinking about Java AWT Toolkit, but when working with JavaFx, this is just so dead easy. Much obliged. :)
ReplyDeleteHelped me in 2016
ReplyDeleteIt worked differently on the past, now it ignore fixed task-bars or panes from system, if you need a hardware scope information, the true resolution of your monitor, you can use GraphicsEnvironment to get your GraphicDevice list and so on get its configurations.
ReplyDelete