Hello,
I am trying to display text(JLabel) above a 3 x3 tic tac toe grid. The JLabel is not displayed. Only the grid shows up. I would be grateful for any help.
Thank you!
import java.awt.*;
import javax.swing.*;
import java.applet.Applet;
public class Game extends JApplet
{
LayoutManager layout;
private JPanel panel [] = new JPanel [5];
private GridLayout grid;
private JButton button [] = new JButton [10];
private JLabel label [] = new JLabel [5];
private JTextField field [] = new JTextField [10];
public void init()
{
setBackground(Color.GRAY);
layout = new BoxLayout (this,BoxLayout.Y_AXIS);
grid = new GridLayout (3, 3, 5, 5);
panel[1] = new JPanel();
panel[1].setLayout (new FlowLayout());
label[1] = new JLabel ("----------------- | TIC TAK TOE | -------------------");
panel[1].add (label[1]);
panel[2] = new JPanel();
panel[2].setLayout (grid);
for (int i = 1; i <= 9; ++i)
{
button[i] = new JButton();
panel[2].add (button[i]);
}
add (panel[2]);
add (Box.createRigidArea(new Dimension (100, 100)));
add (panel[1]);
}
}