Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(frame.getGraphicsConfiguration());
Rectangle desktopBounds = new Rectangle(
screenInsets.left, screenInsets.top,
screenSize.width - screenInsets.left - screenInsets.right,
screenSize.height - screenInsets.top - screenInsets.bottom);