Hey all, very simple question here..
How in Java can I get a Rectangle object that represents the Desktop coordinates?
In fact just the width and height of the Desktop will do..
I'm just looking for something similar to the following C code

HWND hDesktop;
hDesktop = GetDesktopWindow();
if ( hDesktop != NULL )
{
    RECT rcDesktop;
    if ( GetWindowRect( hDesktop , &rcDesktop ) )
    {
         // Do something with rcDesktop
     }
}

Thanks,
Jonathon.

Recommended Answers

All 2 Replies

import java.awt.Dimension;
import java.awt.Toolkit;

public class ScreenResolution {
	
	public static void main(String[] args) 
	{
        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
        System.out.println("Dimention is "+(int)dim.getWidth()+"x"+(int)dim.getHeight());
    }
}

Worked perfect, thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.