How to “correctly” detect DPI of display with Java?

后端 未结 1 1411
梦如初夏
梦如初夏 2020-12-01 16:25

I have the following app that draws a rule :

public class Rule extends JComponent
{
  public static final long serialVersionUID=26362862L;
//  public static          


        
相关标签:
1条回答
  • 2020-12-01 17:13

    Driver problem.

    The real DPI is known only to driver, which reports it to the OS, which reports it to Java and other applications. Since not only Java has the wrong scale, it must be the driver.

    This is ages old problem. Many graphical applications have a global setting "screen DPI" where users can adjust for their actual monitor.

    Besides, since you're writing in Java, keep in mind that some OSes have no means of telling Java the real DPI (because they don't know themselves). The need for DPI configuration setting is thus even more clear.

    0 讨论(0)
提交回复
热议问题