You don't. There isn't actually a resize() method in JPanel, but there is in Component, but it is deprecated. Read the details in the
API.
If you do alter the size of a Component, you may have to call validate() and pack() on its enclosing Container as well.