How to properly size your JFrame window according to the screen
It's important when programming to think that the screen size for each user who is going to use your app is different. So, you have to resize the window according to the screen resolution.
The ideal dimension is to set the length and width with 2/3 the current monitor dimension. To
retrieve the screen size in java, the java compiler has the
getScreenSize() method of the
Toolkit class. Here's an example:
//retrieve screen dimension
MonitorSize Dimension = Toolkit.getDefaultToolkit().getScreenSize();
int length = monitorsize.width * 2/3;
int height = monitorsize.height * 2/3;
//set the size of JFrame to 2/3 the screen size
frame.setSize(length, height);
Output
You can change the size. For example, instead of 2/3 which would be maybe A little wider in a 12" screen but it never goes over the mark. When developing an application, always remember to follow this technique which is adaptable to all monitors