Suppose I have a JFrame and JPanel. I make the size of JPanel(e.g. size 300*300) smaller than the JFrame(e.g size 500*500) and add the JPanel to the JFrmae's contentPane. I want to always keep the size of the JPanel(e.g it should not expand)and dispay it in the middle of the JFrame, even the JFrame is resized. Can anyone please tell me how can I do this?