I am doing a project on Nqueens and i need dynamically show the movement of queens but the screen shows only the final o/p and not the proc ess of how is it working!How can i visualize each step!
i am giving a part of that code
i am giving a part of that code
Code:
//THIS FOR CREATING CHESS BOARD
p3.setLayout(new GridLayout(i,i));
gbl=new GridBagConstraints();
for(int m=0;m<i;m++)
{
for(int n=0;n<i;n++)
{
gbl.gridx=m;
gbl.gridy=n;
l[m][n]=new JLabel();
l[m][n].setOpaque(true);
if((m+n)%2==0)
{
l[m][n].setBackground(Color.black);
l[m][n].setIcon(new ImageIcon("wb.jpg"));
p3.add(l[m][n],gbl);
}
else
{ l[m][n].setBackground(Color.white);
l[m][n].setIcon(new ImageIcon("ww.jpg"));
p3.add(l[m][n],gbl);
}
}
}
//THIS IS TO DYNAMICALLY GENERATE
for(int hh=0;hh<n;hh++)
{ for(int m=0;m<n;m++)
{
if(l[hh][m].getIcon()!=null)
l[hh][m].setIcon(null);
}
}
if((k+ii)%2==0)
{
l[k][ii].setIcon(new ImageIcon("wb.jpg"));
//p3.add(l,gbl);
}
else
{
l[k][ii].setIcon(new ImageIcon("ww.jpg"));
//p3.add(l,gbl);
}
Comment