JavaFX provides an easy option to get screen dimensions (screen size) of all the monitors connected. This can be done using the javafx.stage.Screen class.
Get Screen Size of Primary Monitor
import javafx.application.Application; import javafx.geometry.Rectangle2D; import javafx.stage.Screen; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage primaryStage) { //Get primary screen bounds Rectangle2D screenBounds = Screen.getPrimary().getBounds(); System.out.println(screenBounds); System.exit(0); } }
Example Output
Rectangle2D [minX = 0.0, minY=0.0, maxX=1920.0, maxY=1080.0, width=1920.0, height=1080.0]
Get Number Of Monitors / Visual Devices
Let’s see how we can find number of monitors currently attached to the system using the JavaFX Screen API.
import javafx.application.Application; import javafx.stage.Screen; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage primaryStage) { System.out.println(Screen.getScreens().size()); System.exit(0); } }
Example Output
2
Get Screen Size Of All Monitors
import javafx.application.Application; import javafx.collections.ObservableList; import javafx.stage.Screen; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage primaryStage) { ObservableList<Screen> screenSizes = Screen.getScreens(); screenSizes.forEach(screen -> { System.out.println(screen.getBounds()); }); System.exit(0); } }
Example Output
Rectangle2D [minX = 0.0, minY=0.0, maxX=1920.0, maxY=1080.0, width=1920.0, height=1080.0] Rectangle2D [minX = -1920.0, minY=0.0, maxX=-384.0, maxY=864.0, width=1536.0, height=864.0]
… [Trackback]
[…] Info on that Topic: genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/ […]
… [Trackback]
[…] Read More Info here on that Topic: genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/ […]
… [Trackback]
[…] Find More on that Topic: genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/ […]
… [Trackback]
[…] Read More here on that Topic: genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/ […]
… [Trackback]
[…] Find More Information here to that Topic: genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/ […]
… [Trackback]
[…] Info on that Topic: genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/ […]
… [Trackback]
[…] Find More on to that Topic: genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/ […]
… [Trackback]
[…] Find More here on that Topic: genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/ […]
… [Trackback]
[…] Read More Info here on that Topic: genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/ […]
… [Trackback]
[…] Read More here on that Topic: genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/ […]
… [Trackback]
[…] Read More Info here on that Topic: genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/ […]
… [Trackback]
[…] There you will find 26160 additional Information to that Topic: genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/ […]
… [Trackback]
[…] Find More on on that Topic: genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/ […]
… [Trackback]
[…] Info to that Topic: genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/ […]
… [Trackback]
[…] Read More Information here to that Topic: genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/ […]
… [Trackback]
[…] Read More on that Topic: genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/ […]
… [Trackback]
[…] Find More Info here to that Topic: genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/ […]
… [Trackback]
[…] Read More Information here on that Topic: genuinecoder.com/javafx-get-screen-size-of-all-connected-monitors/ […]