simple game with swing and awt problem
ok so ive to create a gui game that matches pictures together but im having trouble with the following bit of code, if i un-comment the if statements i get the error "cannot find symbol symbol : method getActioncommand()",it works fine with one if statement??? can anyone please help
Code :
public void actionPerformed(ActionEvent e)
{
String message = "";
if(e.getActionCommand() == "pic1") message = "you clicked on the first button - pic1";
//if(e.getActioncommand() == "pic2") message = "you clicked on the second button - pic2";
//if(e.getActioncommand() == "pic3") message = "you clicked on the third button - pic3";
//if(e.getActioncommand() == "pic4") message = "you clicked on the fourth button - pic4";
//if(e.getActioncommand() == "pic5") message = "you clicked on the fifth button - pic5";
//if(e.getActioncommand() == "pic6") message = "you clicked on the sixth button - pic6";
//if(e.getActioncommand() == "pic7") message = "you clicked on the seventh button - pic7";
//if(e.getActioncommand() == "pic8") message = "you clicked on the eight button - pic8";
//if(e.getActioncommand() == "pic9") message = "you clicked on the nineth button - pic9";
//if(e.getActioncommand() == "pic10") message = "you clicked on the tenth button - pic10";
//if(e.getActioncommand() == "pic11") message = "you clicked on the eleventh button - pic11";
else message = "you clicked on the twelfth button - pic12";
System.out.println((e));
JOptionPane.showMessageDialog(null, message, "Match The Picture's", JOptionPane.ERROR_MESSAGE);
Re: simple game with swing and awt problem
java is case sensitive...see the API for ActionEvent, namely the "getActionCommand" method
Re: simple game with swing and awt problem
thanks again copeg, ive been looking at that program for ages trying to figure out where i went wrong, its all just one big pile of mush :)