Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: simple game with swing and awt problem

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    11
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default 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

    	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);


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: simple game with swing and awt problem

    java is case sensitive...see the API for ActionEvent, namely the "getActionCommand" method

  3. The Following User Says Thank You to copeg For This Useful Post:

    Pulse_Irl (October 12th, 2010)

  4. #3
    Junior Member
    Join Date
    Feb 2010
    Posts
    11
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default 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

Similar Threads

  1. Simple game in Java
    By velop in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 27th, 2010, 05:04 AM
  2. Replies: 8
    Last Post: December 9th, 2009, 04:45 PM
  3. Simple Game In Java (Head and Tails).
    By drkossa in forum Java Theory & Questions
    Replies: 5
    Last Post: November 28th, 2009, 11:40 AM
  4. not so simple, simple swing question box
    By wolfgar in forum AWT / Java Swing
    Replies: 2
    Last Post: November 20th, 2009, 03:47 AM
  5. Problem while programming a simple game of Car moving on a road
    By rojroj in forum Java Theory & Questions
    Replies: 3
    Last Post: April 2nd, 2009, 10:24 AM