At first i want the frame to be Divided into two panels and then add buttons on it . This is where the problem is coming. The button is not visible on the panel . It is visible when i remove the second panel . Another question is that can i control the size of the button on it?
The CardLayout is like a bunch of cards placed one over the other. So when you remove the one on the top you can see the one under it. To divide a panel into 3 you have to use a panel which implements GridLayout. The grid must have one row and three columns. In each you have to use seperate panels. That will work. Try it out. Anyway the CardLayout will not work.