set size wont work in java

In Swing, you have two options for layout: do everything manually or let a LayoutManager handle it for you.

Calling setSize() will only work when you’re not using a LayoutManager. Since you’re using a GridLayout you’ll have to use other ways to specify what you want.

Try calling setPreferredSize() and setMinimumSize().

Leave a Comment