-1

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;

leppie
  • 115,091
  • 17
  • 196
  • 297
needermen
  • 43
  • 1
  • 8

1 Answers1

-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