CamHart
CamHart

Reputation: 4335

Java - Get Windows Scale percent

I need to figure out what the scaling is set to. This answer at Windows scaling gives code in c/c++/c#, but I need it in Java and would much prefer to not have to do JNI. Is there a way to use JNA to get that information?

Upvotes: 2

Views: 1759

Answers (1)

CamHart
CamHart

Reputation: 4335

This appears to do it:

GraphicsConfiguration asdf = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();

AffineTransform asfd2 = asdf.getDefaultTransform();

double scaleX = asfd2.getScaleX();
double scaleY = asfd2.getScaleY();

Forgive the bad variable names. And instead of defaults, you may want to account for multiple displays. But that shows how it can be done.

Upvotes: 7

Related Questions