Click to See Complete Forum and Search --> : Auto Image Display code debugging


Paddy Notemaker
01-18-2005, 04:35 PM
Dear all,

I have been working on a java applet that is supposed to automatically display images that are named 1,2,3,etc to the last image. Basically I have a few methods that deal with increasing x (the number) in increments of 1, and a couple more that deal with adding file extensions etc. Basically, the user is supposed to be able to use the arrow keys to alter the x value, right being a positive increase and left being a negative increase. I just cannot see why it is not working. Any help with this code would be great.

Code
----------------------------------------------------------------------

import java.awt.*;
import javax.swing.*;
import java.applet.*;

public class catalogue extends JApplet
{

private int x = 1;
String filexten = ".gif";
String filename = x + filexten ;
public Image picture;

public void init()
{
JRootPane rootPane = this.getRootPane();
rootPane.putClientProperty("defeatSystemEventQueueCheck,Boolean.TRUE);
}
public void start() {}
public void stop() {}
public boolean keyDown(Event e, int key)
{
if(key == Event.LEFT)
{
x--;
}
if(key == Event.RIGHT)
{
x++;
}
if(key == Event.DOWN)
{
x = 1;
}
return true;
}
public String filename()
{
return x + filexten;
}
public void update(Graphics g)
{
String filexten = ".gif";
String filename = x + filexten ;
picture=getImage(getDocumentBase(),"filename()");
if (picture == null)
{
g.drawImage(picture,0,0,this);
}
g.drawImage(picture,0,0,this);
}
public void run() {}

}

----------------------------------------------------------------------
End Code

Thanks to all.

ray326
01-18-2005, 05:13 PM
Go back and compare to your Animator class that used an almost identical IO. It seems you're just not hooked into the events at all here.