Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2011
    Posts
    36
    Thanks
    1
    Thanked 0 Times in 0 Posts

    What is wrong with this code?

    I have this code
    Code:
    /**
     * @(#)slime.java
     *
     * slime Applet application
     *
     * @author 
     * @version 1.00 2012/4/18
     */
     
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    
    public class slime extends java.applet.Applet implements KeyListener {
    	
    	Graphics screen, offscreen;
    	Image workspace;
    	int character_int;
    	slimeSprite green;
    	
    	public void init() {
    		
    		requestFocus();
    		addKeyListener(this);
    		workspace=createImage(600,400);
    		offscreen=workspace.getGraphics();
    		green=new slimeSprite(50,50,100,100);
    		
    	}
    	
    	public void keyPressed(KeyEvent event) {
    		
    		character_int=event.getKeyCode();
    		
    		
    		
    	}
    	
    	public void keyReleased(KeyEvent event) {
    	}
    	
    	public void keyTyped(KeyEvent event) {
    	}
     
    	public void paint(Graphics screen) {
    		
    		green.getcolor(Color.green);
    		green.drawslime(screen);
    		
    	}
    }
    and then this class code
    Code:
    import java.awt.*;
    public class slimeSprite {
    	
    	int x, y, height, width;
    	Color mycolor;
    	
    	public slimeSprite(int left,int top,int h,int w) {
    
    		x=left;
    		y=top;
    		height=h;
    		width=w;
    		
    	}
    	
    	public void getcolor(Color clr) {
    		mycolor=clr;
    	}
    	
    	public void drawslime(Graphics screen) {
    		
    		screen.setColor(mycolor);
    		screen.fillOval(x,y,height,width);
    		screen.setColor(Color.white);
    		screen.fillRect(x+(height/2),y,2/height,width);
    		
    	}
    	
    }
    and it bring up the error: cannont find cymbol class slimeSprite.

    what is wrong?

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    During compile or runtime?
    Make sure that the slimesprite is a part of the classpath available when running the applet. Easiest thing to do is simply package it up from an IDE since it will do this work for you, otherwise follow the documentation in javac: http://docs.oracle.com/javase/1.3/do...n32/javac.html


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •