This site requires JavaScript, please enable it in your browser!
Greenfoot back
shern91
shern91 wrote ...

2013/11/13

Cannot find symbol - variable color

shern91 shern91

2013/11/13

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class MoveRightTile here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class MoveRightTile extends Tile
{
    /**
     * Act - do whatever the MoveRightTile wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    //MoveRightTile r = new MoveRightTile();
    public void MoveRightTile()
    {
     displayMessage("Ouch",Color.red);    
    }
    
}
why always i get the error cannot find symbol - variable color,i just wan create a arrow after user click will display"Tile clicked"
bourne bourne

2013/11/13

#
Add: import java.awt.Color; at the top of your file before or after: import greenfoot.*;
shern91 shern91

2013/11/13

#
Thank you very much...but now another error...cannot find symbol - method displayMessage(java.lang.String.awt.Color)
GreenHouse GreenHouse

2013/11/13

#
Class MoveRightTile or Class Tile need to have the method displayMessage, which you try to call in line 18. Do they?
shern91 shern91

2013/11/13

#
how to call in line 18? i am fresh in greenfoot...
davmac davmac

2013/11/13

#
Where is the "displayMessage" method defined? What does its declaration look like?
shern91 shern91

2013/11/13

#
how to defined the displayMessage method
GreenHouse GreenHouse

2013/11/13

#
Okay, from the beginning ;) In line 18 you do the following: displayMessage("Ouch",Color.red) You call the method 'displayMessage', but this method is not defined inside your class. You need to creade this method first. Or where did you get the code from? The method should look like this
void displayMessage(String text, Color color) {
  // do something in here
}
shern91 shern91

2013/11/14

#
this code is my lecture given as a lab...and she give some example show us and i have to done stage 1 to stage 8...the above code is stage 4...thx you very much
shern91 shern91

2013/11/14

#
actually i want to do displayMessage when the MoveRightTile is clicked will pop up a window and display message "ouch"
shern91 shern91

2013/11/14

#
the question is add a statment in MyWorld class' constructor to create a MoveRightTile object. *how do i create a new constructor MoveRightTile object in MyWorld example MoveRightTile r = new MoveRightTile();//<-like this? add the created MoveRightTile object into the world at(500,300)
shern91 shern91

2013/11/14

#
i did it...addObject(r,500,300)..thank to everyone for helped i..
You need to login to post a reply.