title: GUI elements on different screens with same resolution but different size
body: <p>I wrote a little Java program for a friend of mine, we have the same resolution ( 1920 * 1080 ), but his Screen in general is smaller than mine. To solve the problem I gave the GUI elements percentual coordinates, which works perfectly until I use fonts. The <code>Font</code> will be the same size, like mine which is like the code expects. The Bounds for a <code>JButton</code> for example says where to start where to end, but a font measured in points, so each inch has 72 points, a Font with 30 will always be half an inch. (Compare to the Images)</p>
  <p>How can I fix this, I found nothing that could solve the problem in my eyes?</p>
  <p>Image Before:
  <a href="https://ibb.co/HXf0pt4" rel="nofollow noreferrer">https://ibb.co/HXf0pt4</a></p>
  <p>Image After:
  <a href="https://ibb.co/1sbKyts" rel="nofollow noreferrer">https://ibb.co/1sbKyts</a></p>
  <pre class="lang-java prettyprint-override"><code>public class DrawMenu extends JLabel{
      
      private static final long serialVersionUID = 1L;
  
      protected void paintComponent(Graphics g) {
          
          super.paintComponent(g);
          
          Graphics2D g2d = (Graphics2D) g;
  
          g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  
          int sw = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();
          int sh = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
            
          g.setFont(new Font(&quot;TimesRoman&quot;, Font.PLAIN, (int)Math.round(sw * 0.0078)));
          g.drawString(&quot;Termine die nächsten 0 bis 7 Tage&quot;, (int)Math.round(sw * 0.026), (int)Math.round(sh * 0.176));
          g.drawString(&quot;Termine die nächsten 8 bis 14 Tage&quot;, (int)Math.round(sw * 0.182), (int)Math.round(sh * 0.176));
          
          repaint();
      }
      
  }
  </code></pre>
  <pre class="lang-java prettyprint-override"><code>public class Gui {
  
      static JFrame jfCounter, jfMenu, jfTask;
      static DrawCounter drawc;
      static DrawMenu drawm;
      static DrawTask drawt;
      static JButton kEnde, kNC, kA, kL, kEsc1, kEsc2, kEsc3, kEsc4, kEsc5, kLG, kLB, kAS, kEnter, kJFsw1, kJFsw2, kJFsw3,
              kJFsw4, ko[] = new JButton[6], kSettings, ktw, ktla, ktle, ktlb, ktnt;
      static JTextArea taAusgabe, taAusgabedw, taAusgabenw, taze, tabe, tati;
      static JFormattedTextField nfTag, nfMonat, nfJahr, nfTagA, nfMonatA, nfJahrA;
      static JTextField tfAnlass, tfkLBestimmt, tfAnlassA, tfAnlassAS, tfKonsole, tfKonsoleT, tfsettings[] = new JTextField[12], tftw,
              tftis, tftlbs, tftnct, tftnci;
  
      public Gui() {
  
          int sw = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();
          int sh = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
  
          System.out.println(sw + &quot; &quot; + sh);
  
          // JFrame Settings
          jfCounter = new JFrame();
          jfCounter.setSize(sw, sh);
          jfCounter.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          jfCounter.setLocationRelativeTo(null);
          jfCounter.setExtendedState(JFrame.MAXIMIZED_BOTH);
          jfCounter.setTitle(&quot;Tageszähler&quot;);
  
          jfMenu = new JFrame();
          jfMenu.setSize(sw, sh);
          jfMenu.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          jfMenu.setLocationRelativeTo(null);
          jfMenu.setExtendedState(JFrame.MAXIMIZED_BOTH);
          jfMenu.setTitle(&quot;Menü&quot;);
  
          jfTask = new JFrame();
          jfTask.setSize(sw, sh);
          jfTask.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          jfTask.setLocationRelativeTo(null);
          jfTask.setExtendedState(JFrame.MAXIMIZED_BOTH);
          jfTask.setTitle(&quot;Task&quot;);
  
          // JButtons
          Border bor = BorderFactory.createLineBorder(Color.BLACK, 1);
          Border boresc = BorderFactory.createLineBorder(Color.RED, 3);
  
          kEnde = new JButton(&quot;Ende&quot;);
          kEnde.addActionListener(new ActionHandler());
          kEnde.setBounds((int) Math.round(sw * 0.026), (int) Math.round(sh * 0.509), (int) Math.round(sw * 0.195),
                  (int) Math.round(sh * 0.028));
          kEnde.setBorder(bor);
          jfCounter.add(kEnde);
  
          kNC = new JButton(&quot;Neuer Counter&quot;);
          kNC.addActionListener(new ActionHandler());
          kNC.setBounds((int) Math.round(sw * 0.026), (int) Math.round(sh * 0.028), (int) Math.round(sw * 0.078),
                  (int) Math.round(sh * 0.028));
          kNC.setBorder(bor);
          jfCounter.add(kNC);
  
          // JLabel / Draw
          drawc = new DrawCounter();
          drawc.setBounds(0, 0, sw, sh);
          drawc.setVisible(true);
          jfCounter.add(drawc);
  
          drawm = new DrawMenu();
          drawm.setBounds(0, 0, sw, sh);
          drawm.setVisible(true);
          jfMenu.add(drawm);
  
          drawt = new DrawTask();
          drawt.setBounds(0, 0, sw, sh);
          drawt.setVisible(true);
          jfTask.add(drawt);
  
          // JFrame Final Visible
          Gui.getJfMenu().setVisible(true);
  
      }
  </code></pre>