Chess moving in Java
for(y=0;y
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 want e(the JButton I originally selected) to go to r(the JButton that I
selected second)
No comments:
Post a Comment