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.
You just set the visibility of this component (JPanel) as follow:

```
JPanel panel = new JPanel();
//set your custom size in this with=120; height=570;
panel.setSize(120,570);
panel.setVisible(false);
panel.setVisible(true);
//hope this help! :)

```