I intended to make a JFrame with a ContentPanel of 600x600 and I wanted the JFrame to be not re-sizable. Inside this box, I Drew a 600x600 red-outlined rectangle to make sure that everything matched when i ran the program. Before restricting resizing for the JFrame, I set the size of my JFrame by doing:
getContentPane().setPreferredSize( new Dimension(600,600));
pack();
And when I launched the program and the boundaries of my rectangle fit perfectly with the dimensions of the JFrame. However, when i added isResizable(false) into the equation, there seemed to be buffer of pixels between the right edge of my rectangle as well as the bottom edge of my rectangle. With a little trial and error, it seems as though isResizable(false) adds 10 pixels to height and width. (So having dimension of 590x590 for contentPane + the extra 10 is my workaround)
My Questions why is this? I can't seem to find any documentation about the extra 10 pixels anywhere?
Note: This anomaly was also also observed by making a JFrame without modifying the size. Without making it un-resizable, there is no observable panel/contentPane, but when isResizable(false) is used, there is visible part of the panel/pane.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…