so i have two class.
1 = Main.java - 2 = Player.java
AND
my folder tree

-src
    -images
        player_walk_right.gif
    -Main.java
    -Player.java

Player.java

public class Player 
{
    Image player_image = getImage(getDocumentBase(),"player_walk_right.gif");

    /*** constructor Method ***/
    public Player()
    {
        //empty constructor 
    }
    public Player(int ix, int iy)
    {
        x = ix;
        y = ix;
    }   

    /*** get/set method ***/
        public Image  getImages() 
        { return player_image; }

    /*** paint method ***/
        public void paint(Graphics g) 
        {
            g.drawImage(player_image, 0, 0, null);
        }/*** paint method ***/
}/*** end of class ***/

Main.java :

public class Main extends Applet implements Runnable
{

    /*** start method ***/
    @Override
    public void start()
    {
        player_class = new Player();
        Thread thread = new Thread(this);
        thread.start();
    }/*** end of start method ***/

    /*** run method ***/
    public void run()
    {
        while(true) //player moves
        {
            player_class.update(this);
            repaint();
            try
            {
                Thread.sleep(17);
            }
            catch(InterruptedException e)
            {
                e.printStackTrace();
            }
        }
    }/*** end of run method ***/
    /*** paint method ***/
    @Override
    public void paint(Graphics g) 
    {
        player_class.paint(g);  //call Player class, which will draw player
    }/*** end of paint method ***/
 }


error - The method getDocumentBase() is undefined for the type Player

any ides's?????

The message is perfectly clear - you defined a Player class and it doesn't have a getDocumentBase method. That method is defined in the Applet class. Main extends Applet, so you can call the method there and maybe pass the result to PLayer's constructor, or maybe proving a tiny get method in Main that the otehr class(es) can call to get the doc. base.

ps: Applet was effctively superceeded by JApplet abouta decade ago.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.