Problem Setting offscreen background

Hi

I'm trying to create an applet with an image moving down the screen which i have been able to do, but when i try to set background of the offscreen image i get the following when compiling : symbol : method setBackground(java.awt.Color). Is there another way to set the offscreen background. Here is the code.

Many Thanks

Dean

import java.awt.*;

publicclass KelvinIndexLogoextends java.applet.Appletimplements Runnable{

// Define Objects & Variables

Image logo, workspace;

Graphics offscreen;

Thread runner;

int logoY = 0;

int logoStop;

// Background RGB values

int backRed= 221;

int backGreen = 221;

int backBlue = 221;

boolean firstRun =true;

publicvoid init(){

String imageName = getParameter("logo");

setBackground(new Color(backRed, backGreen, backBlue));

// Get the logo image if the logo parameter has been specified

if(imageName !=null){

logo = getImage(getCodeBase(), imageName);

}

}

publicvoid start(){

if(runner ==null){

runner =new Thread(this);

runner.start();

}

}

publicvoid stop(){

if(runner !=null){

runner =null;

}

}

publicvoid run(){

// Move the Logo down from the top of the applet

Thread thisThread = Thread.currentThread();

while(runner == thisThread){

repaint();

try{

Thread.sleep(50);

}catch(InterruptedException e){}

// Would not get the correct image height in the init method

// therefore created first run bolean to set the start & Stop points

if(firstRun){

logoY= 0 - logo.getHeight(this);

logoStop = getSize().height - logo.getHeight(this);

firstRun =false;

}

logoY++;

if(logoY == logoStop){

runner =null;

}

}

}

publicvoid paint(Graphics screen){

// Create the workspace & offscreen objects on each iteration so

// image is cleared every time and no black trail appears on text

workspace = createImage(getSize().width, getSize().height);

offscreen = workspace.getGraphics();

offscreen.setBackground(this.getBackground());

if(logo !=null){

offscreen.drawImage(logo, 0, logoY,null);

}

// Draw workspace to screen & set background colour

screen.drawImage(workspace, 0,0,this);

}

publicvoid update(Graphics screen){

paint(screen);

}

}

Message was edited by:

D34N0

Message was edited by:

D34N0

[5325 byte] By [D34N0a] at [2007-11-27 10:29:12]
# 1

> I'm trying to create an applet with an image moving

> down the screen which i have been able to do, but

> when i try to set background of the offscreen image i

> get the following when compiling : symbol : method

> setBackground(java.awt.Color).

How are you folks writing code? Wildly typing any method name and hoping it exists and does what you want?

Fill a rectangle with the color you want, with the size of the image.

CeciNEstPasUnProgrammeura at 2007-7-28 17:56:08 > top of Java-index,Java Essentials,Java Programming...
# 2

> > I'm trying to create an applet with an image

> moving

> > down the screen which i have been able to do, but

> > when i try to set background of the offscreen image

> i

> > get the following when compiling : symbol :

> method

> > setBackground(java.awt.Color).

>

> How are you folks writing code? Wildly typing any

> method name and hoping it exists and does what you

> want?

>

> Fill a rectangle with the color you want, with the

> size of the image.

Thank you CeciNEstPasUnProgrammeur. I have only just started using Java and new to the concept. I have only taken a couple of online courses that have given me the outlines.

Many Thanks

Dean

D34N0a at 2007-7-28 17:56:08 > top of Java-index,Java Essentials,Java Programming...
# 3

Let me introduce you to something called "documentation". You might want to read what it says about some classes and methods before you use them.

http://java.sun.com/j2se/1.5.0/docs/api/

CeciNEstPasUnProgrammeura at 2007-7-28 17:56:08 > top of Java-index,Java Essentials,Java Programming...