Suppose I have a JPanel in a JFrame. When I invoke a method that changes the preferred size of that JPanel, it does not change.
The code looks something like this:>
Add frame.pack(); after somePanel.expand(); in your main() method. It will be done.
frame.pack();
somePanel.expand();
main()