Toolkit.getDefaultToolkit()方法返回null, 我该怎么解决?我想获得这样的屏幕宽度和高度 - > Dimension screenSize =(Dimension)(Toolkit.getDefaultToolkit()。getScreenSize()); int creenHeight = screenSize.height; int screenWidth = screenSize.width;
答案 0 :(得分:0)
GraphicsDevice monitors[]=GraphicsEnvironment.getScreenDevices();
Dimension screen_resolution[monitors.length];
for (int monitorID = 0; monitorID < monitors.length; monitorID++)
{
screen_resolution[monitorID] = new Dimension(monitors[monitorID].getDisplyMode().getWidth(),monitors[monitorID].getDisplyMode().getHeight());
}