when u add components to a container with a cardLayout u need to add them like this: the name of the component, string to describe it. exactly like the add u have in comments. the exception is for the add(b) with no string describing it. add(Component,String) is the right way for cardLayout. the reason u need the string is that u can later switch to that card using the name u gave it.