title: Make a game full-screen while keeping to scale for any screen
body: <p>I just finished making my first game in Java and want to put my game into fullscreen while keeping the game to scale. I'm using Swing and running the game through a <code>JFrame</code>.</p>
  <p>How would I go about doing this?</p>
  <pre class="lang-java prettyprint-override"><code>package com.game.main;
  
  import java.awt.Canvas;
  import java.awt.Dimension;
  import java.io.Serial;
  
  import javax.swing.JFrame;
  
  public class Window extends Canvas{
  
  @Serial
  private static final long serialVersionUID = -1478604005915452565L;
  
  public Window(int width, int height, String title, Game game) {
      JFrame frame = new JFrame(title);
      
      frame.setPreferredSize(new Dimension(width,height));
      frame.setMaximumSize(new Dimension(width,height));
      frame.setMinimumSize(new Dimension(width,height));
      
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setResizable(false);
      frame.setLocationRelativeTo(null);
      frame.add(game);
      frame.setVisible(true);
      game.start();
  }
  </code></pre>