Using a FlowLayout on top of a CardLayout
I want to use multiple panels as cards in a cardlayout. Therefore I created one Panel with cardLayout and multiple panels with flowlayout, and added those to the first panel.
The following code is part of my "gui extends JFrame" class:
Everything works fine so far. But I would like to use the flowlayout, so that components are automatically arranged on the underlying panel, e.g. moved to the next line when making the window smaller. If I don't use cardLayout this works just fine. Now it doesn't. Any ideas what might be the reason for this?
JPanel cards = new JPanel(new CardLayout());
UnitCard unitPanel = new UnitCard(new FlowLayout(FlowLayout.LEFT, 10, 10));
Thanks for your help!