for(y=0;y<length;y++){
for(x=0;x<width;x++){
grid[x][y]=new JButton(" ");
grid[x][y].addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
((JButton)e.getSource()).setBorder(border);;
System.out.println("Where do you want to move this piece");
}
});
grid[x][y].addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent r){
grid[x][y]=grid[x][y-1];
((JButton)r.getSource()).setBorder(border);;
System.out.println("Derp");
}
});
frame.add(grid[x][y]);
}
}
I want to click a piece and then when you click a different square, the piece will move up one. I know this is wrong and I will show the legal moves but for right now I need to get the pieces moving. Please help!! I am completely stuck until I can get this figured out.