Please help me add actionlistener ect. to my puzzle program so that i can move the tiles into ascending order..Here is my code..
import javax.swing.*;
import java.awt.*;
import java.util.Random;
public class Rand {
private JButton btn[]=new JButton[16];
public static void main(String args[])
{
Rand app=new Rand();
}
public Rand(){
JFrame frame=new JFrame("Rotaion ver 1.2");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel=new JPanel(new GridLayout(4,4));
int minValue=1;
int maxValue=15;
int numInts=15;
int range=maxValue-minValue;
Random r=new Random();
int[] randomInts=new int[numInts];
int nextRandom;
for(int i=0;i<numInts;i++)
{
nextRandom=r.nextInt(range + 1) + minValue;
randomInts[i]=nextRandom;
for(int j=0;j<i;j++){
if(nextRandom==randomInts[j]){
i--;
j=i;
}
}
}
for(int x=0;x<15;x++){
btn[x]=new JButton(randomInts[x]+"");
panel.add(btn[x]);
if(x==15){
btn[x].setVisible(false);
}
}
frame.add(panel);
frame.setSize(500,500);
frame.setResizable(false);
frame.setVisible(true);
}
}
here is my output..pls help..email me @:..Thanks