import java.awt.*;
import javax.swing.*;
public class Panels extends JApplet
{
private Container c = getContentPane();
public void init()
{
BorderLayout bl = new BorderLayout();
setLayout(bl);
add(new JButton("East "), BorderLayout.EAST);
add(new JButton("West "), BorderLayout.WEST);
add(new JButton("North "), BorderLayout.NORTH);
add(new JButton("South "), BorderLayout.SOUTH);
addCenterPanel();
}
void addCenterPanel()
{
JPanel p = new JPanel();
setLayout(new BorderLayout());
add(new JButton("Right "), BorderLayout.EAST);
add(new JButton("Left "), BorderLayout.WEST);
add(new JButton("Up "), BorderLayout.NORTH);
add(new JButton("Down "), BorderLayout.SOUTH);
addInnermostPanel();
}
void addInnermostPanel()
{
JPanel center = new JPanel();
center.setLayout(new BorderLayout());
add(new JButton("> "), BorderLayout.EAST);
add(new JButton("< "), BorderLayout.WEST);
add(new JButton("^ "), BorderLayout.NORTH);
add(new JButton("v "), BorderLayout.SOUTH);
add(new JButton("O"), BorderLayout.CENTER);
}
}
I want the panels to display inside of each other (in the CENTER region) , but they are printing on top of each other and for whatever reason I cant figure out what Im missing. Thanks in advance, any help is appreciated