I set the size of my window as 640 x 1136, and I'm running the program on a 13-inch MBP, which has a resolution of 2560 x 1600. I'm assuming that the window should be able to fully displayed on my screen, but it only shows the top half.
Here's my code.
public static final int WIDTH = 640; // width of window
public static final int HEIGHT = 1136; // height of window
public static void main(String[] args) {
JFrame frame = new JFrame();
World world = new World();
frame.add(world);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(WIDTH, HEIGHT);
frame.setLocationRelativeTo(null);
frame.setVisible(true); // 1) set window visible 2) paint() asap
world.action(); // start the program
}
Here's how it looks like on my screen:
I tried to play around with the parameters and I found that when the HEIGHT is around 800, the window would exceed the screen. How can the max window height be only 1/2 of the resolution of the screen?
And is there a way to increase or decrease the size of the window according to the screen size automatically while keeping everything in scale?
Thanks!