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: 
You may have to [validate](http://download.oracle.com/javase/6/docs/api/java/awt/Container.html#validate%28%29) and repaint your panel. Try following:

```
int x=panel.getWidth();
panel.setSize(x,1000);
panel.validate();
panel.repaint();

```
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()`.