0

It has two JPanels. The first has a sidebar and the other has a title bar.

I want When hiding the first one, the other container to be resized. For example as in the following image :

Before hiding the Menu:

After hiding the Menu:

How can this be done?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
  • 1
    You will need to use the appropriate [layout manager](https://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html) – c0der May 02 '20 at 05:18
  • I could suggest you one thing, whenever you are minimizing the other jpanel at same time you have increase the size of the other panel size(Bigger one). Use it for a temporary work... – Kumar Anil Chaurasiya May 02 '20 at 05:25
  • @KumarAnilChaurasiya making one pane grow when another one becomes smaller can be handled automatically by the layout manager. – c0der May 02 '20 at 05:52
  • 1
    Take a look at the first answer to this Stack Overflow question. https://stackoverflow.com/questions/23785804/java-sliding-jpanels – Gilbert Le Blanc May 02 '20 at 06:07
  • @c0der, thanks for letting me know. – Kumar Anil Chaurasiya May 02 '20 at 07:12
  • @GilbertLeBlanc I think the OP is not after the sliding effect but a simple expand-shrink side panel that can be implemented by using an appropriate layout mannager as demonstrated [here](https://repl.it/repls/LightblueCapitalTerabyte) – c0der May 02 '20 at 07:56
  • @c0der: Ok. If the OP clarifies his question, I'll vote to reopen the question. I interpreted "hiding" to mean sliding. Perhaps, that's my error. – Gilbert Le Blanc May 02 '20 at 08:01
  • @GilbertLeBlanc see OP's comment – c0der May 02 '20 at 12:02

0 Answers0