javaswteclipse-rcp

How to detect the windows font size(100%, 125%, 150%) in java


I am using an swt dialog in which the controls get cut off from the screen if I increase the font size(Control Panel-> Display) from smaller(100%) to large(150%) This can be solved using

  1. Scrollable composite or
  2. To resize the controls or font size if the windows size has been changed to larger.

For point 2, I am unable to get the current Windows size. If I get that, the problem can be solved as the scrollable composite isn't suitable for the smaller size.


Solution

  • I did it in the following way:

    Display.getCurrent().getDPI().x
    

    Here, based on the return value(96, 120 or 144) it can be determined if the size is 100%, 125% or 150% respectively