Here is the simple program to understand the way JFrame::setResizable(boolean)
works:
JFrame frame = new JFrame("Test");
JPanel p1 = new JPanel();
FlowLayout fl = new FlowLayout(FlowLayout.LEADING, 0, 0);
//Adding buttons
p1.setLayout(fl);
p1.setBackground(Color.BLACK);
p1.add(new JButton("1"));
p1.add(new JButton("1"));
p1.add(new JButton("1"));
p1.add(new JButton("1"));
p1.add(new JButton("1"));
//Adding to JFrame
frame.add(p1);
frame.pack();
//Here is where the problem comes
frame.setResizable(false);
//The rest...
frame.setLocationRelativeTo(null);
frame.setVisible(true);
And this is what it shows:
Now when I change frame.setResizable(false);
to frame.setResizable(true);
it works as follows (I didn't do any resizings, it's just after the startup) :
QUESTION: Where does the padding in the first example come from? How to make the resizable = false
window as in the second example (i.e. without these paddings).