//how to get the screen size in java
import java.awt.Toolkit;
import java.awt.Dimension;
import javax.swing.JFrame;
public class GetScreenSize {
static JFrame aWindow = new JFrame("This is a Gridbag Layout");
public static void main(String[] args){
Toolkit thekit = aWindow.getToolkit();
Dimension windSize = thekit.getScreenSize();
System.out.println("Your screen resolutions is : " + windSize.width + " : " + windSize.height);
}
}
import java.awt.Dimension;
import javax.swing.JFrame;
public class GetScreenSize {
static JFrame aWindow = new JFrame("This is a Gridbag Layout");
public static void main(String[] args){
Toolkit thekit = aWindow.getToolkit();
Dimension windSize = thekit.getScreenSize();
System.out.println("Your screen resolutions is : " + windSize.width + " : " + windSize.height);
}
}
COMPILATION:
First of all save it with name "GetScreenSize.java" where ever you want suppose in [C:\java].
Open command Prompt [Window+R] , then type "cmd", Press Enter
Switch to location where you have saved your GetScreenSize.java
C:\java
now type
C:\java\javac GetScreenSize.java
First of all save it with name "GetScreenSize.java" where ever you want suppose in [C:\java].
Open command Prompt [Window+R] , then type "cmd", Press Enter
Switch to location where you have saved your GetScreenSize.java
C:\java
now type
C:\java\javac GetScreenSize.java
OUTPUT
Type the code below in command prompt for displaying/getting output
C:|java\java GetScreenSize
Your screen resolution is : 1366 : 768
Type the code below in command prompt for displaying/getting output
C:|java\java GetScreenSize
Your screen resolution is : 1366 : 768
Comments
Post a Comment