Search code examples
javaswingjpanellayout-managercardlayout

How to make panel fit parent in card layout?


I have a JFrame with CardLayout that contains 2 JTappedPane components and 2 JPanel and a side panel with buttons to control switching between panels in the card layout, my problem is when I switch between panels the size of the window changes and shows gaps and I don't know why.

enter image description here

enter image description here


Solution

  • I solved that by setting both the minimum size and the preferred size of my jPanels and jTappedPanes to the exact size of the parent card layout and unchecked the horizontal resizing and vertical resizing for each one of them.