How to change image?

S

SimonSimon

Hello, I am learning Java and I have a question :)

In the panorama applet I draw an image into the screen. Image is in
variable "pano", which is loaded on the beginning. If I click on the
right place on the image, method show_window from applet "target"
should load new image into variable "pano" and the whole picture should
change. But in my case it does not change. Do you know what shoult I do
to change and display image in the variable "pano"?

I hope it is clear enough :)

public class panorama extends Applet
{
public static panorama selfRef = null;
public Image pano;

public void init()
{
selfRef = this;
String s1 = getParameter("panorama");
loadImage(s1);
}

public void loadImage(String mainPicture)
{
pano = getImage(getCodeBase(), mainPicture);
}

public void paint(Graphics g)
{
width = pano.getWidth(this);
/*
...
*/
}
}

public class target extends JApplet
{
String file;

public void show_window(Applet applet)
{
if (file.equals("Train.jpg"))
{
panorama panoramaApplet = null;
panoramaApplet = panorama.selfRef;
panoramaApplet.loadImage("Train.jpg");
}
}
}
 
S

SimonSimon

yeah, some of the code is missing, but this should be enough to
represent my problem
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top