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();

```
For changing width and height of JPanel use **setPreferredSize** method.

```
JPanel folderPanel = new JPanel();      
folderPanel.setPreferredSize(new Dimension(245, 450));// width, height

```