3 回答
TA贡献1835条经验 获得超7个赞
使用工具包,您可以获得以像素为单位的分辨率
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
double width = screenSize.getWidth();
double height = screenSize.getHeight();
TA贡献1831条经验 获得超4个赞
使用 java.awt.Toolkit
将屏幕尺寸作为 Java Dimension 对象后,您可以按如下方式获得高度和宽度:
public static void main(String args[])
{
// java - get screen size using the Toolkit class
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
//the screen height
screenSize.getHeight();
//the screen width
screenSize.getWidth();
System.out.println("screenSize==>>"+screenSize);
System.out.println("Height ==>>"+screenSize.getHeight());
System.out.println("Widht ===>> "+screenSize.getWidth());
}
添加回答
举报