I've been working on a version of a Tetris game and I tried to make a start page. I figured working with 2 panels will do fine but once I press the button the game doesn't run. Here is a piece of the code, where I implemented the panels. Any ideas what I did wrong and how I should have done it?
public class Tetris extends JFrame
{
JLabel statusbar;
private JPanel panel1=new JPanel();
private JPanel panel2=new JPanel();
public Tetris()
{
setResizable(false);
setSize(200, 400);
setTitle("Tetris");
setDefaultCloseOperation(EXIT_ON_CLOSE);
//setLayout(new FlowLayout());
statusbar = new JLabel(" 0");
JButton startButton = new JButton("START");
panel1.add(startButton);
panel2.add(statusbar, BorderLayout.SOUTH);
Board board = new Board(this);
board.addKeyListener(new TAdapter(board));
panel2.add(board);
startButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent arg0) {
add(panel2);
panel1.setVisible(false);
}
});
add(panel1);
//board.start();
}