Java JFrame Size according to screen resolution
You can try using this to maximize the frame:
this.setExtendedState(JFrame.MAXIMIZED_BOTH);
You are calling pack()
which changes the frame size so it just fits the components inside. That's why it is shrinking back I think. Remove the pack()
line and it should work.