Tell me how to get the size of the useful area of ​​the screen. picture

1 answer 1

This code will help:

// Берем размер всего экрана Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); // Определяем высоту панели задач Insets scnMax = Toolkit.getDefaultToolkit().getScreenInsets(getGraphicsConfiguration()); int taskBarSize = scnMax.bottom; // получаем размеры int width = screenSize.width; int height = screenSize.height - taskBarSize; 

UPDATED. If more compact then so, but readability is worse:

 int width = Toolkit.getDefaultToolkit().getScreenSize().width; int height = Toolkit.getDefaultToolkit().getScreenSize().height - Toolkit.getDefaultToolkit().getScreenInsets(getGraphicsConfiguration()).bottom; 
  • And in any way more compact?) As it is not so ethical. But thanks for the answer. - dlarchikov
  • More compact: int width = Toolkit.getDefaultToolkit (). GetScreenSize (). Width; int height = Toolkit.getDefaultToolkit (). getScreenSize (). height - Toolkit.getDefaultToolkit (). getScreenInsets (getGraphicsConfiguration ()).. bottom; - Drac5
  • In principle, why not. )) Thank. How to close the question? - dlarchikov