I have a JPanel
inside a JFrame
, the panel is around 500 x 500 and is basically a game that relies a lot on mouse clicks. However a lot of my users use a 4k monitor and the game looks really small to them. So for a cheap-fix I'm thinking how I'd go about zoom-scaling the panel when you scale up the frame.
Here's basically what my code is now:
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
frame.setLayout(new BorderLayout());
setFocusTraversalKeysEnabled(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel gamePanel = new JPanel();
gamePanel.setLayout(new BorderLayout());
gamePanel.add(this);
gamePanel.setPreferredSize(new Dimension(765, 503));
JMenuBar jmenubar = new JMenuBar();
frame.add(jmenubar);
frame.getContentPane().add(gamePanel, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true); // can see the client
frame.setResizable(true); // resizeable frame
init();
Example Pictures
How it is right now:
How I want to be able to resize it: