Skip to main content


1 reply [Last post]
Joined: 2006-01-05

Hi, question for the Java2D team:

I've noticed that on Windows, GraphicsConfiguration.getDefaultTransform() and GraphicsConfiguration.getNormalizingTransform() always return the identity transform for screen devices, i.e. 72dpi. I realise that getting accurate physical device measurements is impossible since Windows doesnt know how big my screen is. Still, Windows does report a resolution which is usally 96dpi. Other Windows applications base their measurements on this value and consider 96 pixels to be one inch. Infact, Toolkit.getScreenResolution() returns 96 as expected.

I looked at the Mustang sources and was suprised to find that Win32GraphicsConfig includes getXResolution() and getYResolution() methods which are hardcoded to 72! By contrast, X11GraphicsConfig makes native calls to obtain these values.

So why doesnt Win32GraphicsConfig use the same mechanism as the Toolkit to get the screen resolution? Isn't it better if these two APIs are consistent?

It's not a big deal. I can just do a scale based on the Toolkit value instead, since I want my application to appear consistent with similar Windows applications, but i'd rather use getDefaultTransform() if I could. I'm just curious, is there a reason for the screen res being hardcoded at 72dpi?



Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-06-24

Hi Ben,

I just filed bug 6373505 regarding this issue, which should be visible tomorrow at this location:

Resolution independence in Swing UIs is an important topic these days, so we will be addressing issues like the one you mention soon. (The end goal is to make it possible to write Swing applications that look good on both hi- and lo-res displays. It's not an easy problem, but we're working on it.)