I'm making a multiplication table using swing.Its basically made up of JButtons. The table is formed from input from the user. The user selects the size of the table by entering a number. The last thing i need to do with this is create a heading that displays the numbers of the table created. Here is my sample code, if you run it, you'll see that its done for the vertical numbers. How can i get the numbers above and properly formatted to represent each column. Thank you.

```
package lab7;

import java.awt.BorderLayout;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class GUIMultiplicationTable{
JFrame theFrame;
int number = 0;
JPanel panel, answerPanel, topPanel, leftPanel;
JLabel answerLabel, topLabel, leftLabel;

private void createAndShowGui(){
    String x;
    do{
        x = JOptionPane.showInputDialog(null, "Enter the number");
        number = Integer.parseInt(x);
    }while (number <= 0);
    theFrame = new JFrame("Multiplication Table");
    panel = new JPanel(new GridLayout(number, number));

    answerPanel = new JPanel();     
    answerLabel = new JLabel();

    topPanel = new JPanel();
    topLabel = new JLabel();

    leftPanel = new JPanel();
    leftLabel = new JLabel();

    for (int i = 0; i < number; i++){
        JLabel blah = new JLabel(Integer.toString(i + 1));
        panel.add(blah);//add center to label
        for (int j = 0; j < number; j++){

            JButton button = new JButton();
            if (i == 0){

                button.setText(String.valueOf(j + 1));
            }
            if (j == 0){
                button.setText(String.valueOf(i + 1));
            }
            for (int k = 1; k < number; k++)
            {
                if (i == k)
                {
                    button.setText(String.valueOf((j + 1) * (k + 1)));
                }
            }
            button.addActionListener(new ButtonsTableActionListener(i, j));
            panel.add(button);
        }   
    }

    answerPanel.add(answerLabel);
    theFrame.add(answerPanel, BorderLayout.SOUTH);

    topPanel.add(topLabel);
    theFrame.add(topPanel, BorderLayout.NORTH);

    theFrame.add(panel);
    theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    theFrame.pack();
    theFrame.setLocationRelativeTo(null);
    theFrame.setVisible(true);
}
public static void main(String[] args){
    SwingUtilities.invokeLater(new Runnable(){
        public void run(){
            GUIMultiplicationTable h = new GUIMultiplicationTable();
            h.createAndShowGui();
        }
    });
}

private class ButtonsTableActionListener implements ActionListener{
    private int theRow, theColumn;

    public ButtonsTableActionListener(int row, int column){
        theRow = row;
        theColumn = column;
    }

    @Override
    public void actionPerformed(ActionEvent e){
        int value = (theRow + 1) * (theColumn + 1);
        answerLabel.setText("The value is: " + value + ".\nI got that by multiplying \n" +    (theRow + 1) + "x" + (theColumn + 1));
    }
};
}

```