I am writing a Game in Java, and I don't want to use a layout manager for my JFrame. My class extends JFrame, and looks something like this:
//class field
static JPanel contentPane;
//in the class constructor
this.contentPane = new JPanel();
this.contentPane.setLayout(null);
this.setContentPane(contentPane);
I want my JPanel
be exactly 600x600 px, but when I set the size of my JFrame by calling the this.setSize(600,600)
method, the JPanel
size is less than the 600x600 px because the border of the JFrame
window is included too.
How can I set the size of the JPanel to be exactly 600x600 px?
P.S. I have seen all of the previous post and none of them work for me. For example: Get the real size of a JFrame content does not work for me. What else can I do?