Here is a java 8 code, for designing one main panel, two sub panels, and inserting them into a JFrame, and then showing them alternatively with two buttons. //Creating Two sub panels, one main panel, and showing them in a JFrame in a Customized manner.
//Compiled successfully on Java8. May work on lower versions also.
//Standard Naming practices have not been followed.
//My immense gratitude to Netizens of magnanimity.
//To compile this, it should be saved in a text file named ycardlayou.java.
//Compilation at Commandline: yourpathtojava /or javac ycardlayou.java.
//Using the class generated, to see the result: yourpathtojava / or java ycardlayou