Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-18-2012, 05:45 PM   PM User | #1
pineappelle
New Coder

 
Join Date: Jun 2011
Posts: 34
Thanks: 1
Thanked 0 Times in 0 Posts
pineappelle is an unknown quantity at this point
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?
pineappelle is offline   Reply With Quote
Old 04-18-2012, 06:53 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Tags
slime, slimesprite

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:55 AM.


Advertisement
Log in to turn off these ads.