Toolkit.getDefaultToolkit() method returns null, how can I fix it? I want to get screen width and height like this -> Dimension screenSize = (Dimension) (Toolkit.getDefaultToolkit().getScreenSize()); int creenHeight = screenSize.height; int screenWidth = screenSize.width;
Asked
Active
Viewed 338 times
-1
-
what is this? Java? Android? – leppie Jul 15 '14 at 06:41
-
This is java, java.awt.Toolkit class – needermen Jul 15 '14 at 06:44
-
Please post your code [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve) – DavidPostill Jul 15 '14 at 09:47
1 Answers
-1
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());
}

johnny
- 258
- 2
- 12