Question: How to change the height of panel at runtime?

I have some panels inside a `JFrame`, I tried on one of them:

```
int w = panel.getWidth();
panel.setSize(w, 1000);

```

But there's no effect. What's wrong?

Answer: 
Check out this answer:

[set size wont work in java](https://stackoverflow.com/questions/5714214/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."

and 

"Try calling setPreferredSize() and setMinimumSize()."

If you are using a layout manager (you probably are), the layout decides what to do with the 
contained components. setPreferredSize() usually works because the layout usually asks the
contained components what their preferred sizes are, and then arranges the components
based on (among others) that information.
If you put the panel in a LayoutManager (i.e. the parent has a LayoutManager which is BorderLayout by default) that LayoutManager would override the size and thus your call would have no effect.

Try to call `setLayoutManager(null)` on the parent although I'd recommend using a LayoutManager and use `setPreferredSize()`, `setMinimumSize()` and `setMaximumSize()`.