Como colocar botões numa matriz

for(i=0;i<4;i++)
  {
   for(j=0;j<4;j++)
   {
	count++;
	matriz[i][j]=(b = new JButton(img));
	b.setActionCommand("b"+count);
	b.addActionListener(this);
   }
  }

Não estou conseguindo colocar botões numa matriz. Se me poder ajudar com um exemplo agradecia!obrigado!

JButton[] buttons = new JButton[16];
for (int i = 0; i < buttons.length; i++)  {
    buttons[i] = new JButton( ... );
        ...
}