kosmokramer
Programmer
Hey everyone. You'll have to forgive me if I made some dumb mistakes. It has been a while since I did anything with Java. Anyways, I can't seem to figure out what is wrong with this program.
What I want to do is create a simple applet that will take a parameter list of images from a webpage and create a slideshow. I will probably change the layout and stuff like that, but right now I am just trying to get it working!!
Thanks ahead of time,
Paul
Code:
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
public class rotatePictures extends Applet implements ActionListener
{
private Button back,forward;
private int [] imageArray;
private int index = 0;
private Image image;
public void init()
{
back = new Button("Back");
add(back);
back.addActionListener(this);
forward = new Button("Forward");
add(forward);
forward.addActionListener(this);
imageArray = getParameterValues("loadPictures");
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == back)
{
if (index!=0)
{
index--;
image = getImage(getDocumentBase(), imageArray[index]);
}
else
{
index = imageArray.length;
image = getImage(getDocumentBase(), imageArray[index]);
}
}
else if (e.getSource() == forward)
{
if (index!=imageArray.length)
{
index++;
image = getImage(getDocumentBase(), imageArray[index]);
}
else
{
index = 0;
image = getImage(getDocumentBase(), imageArray[index]);
}
}
repaint();
}
public void paint(Graphics g)
{
g.drawImage(image, 50, 50, 150, 150, this);
}
};
What I want to do is create a simple applet that will take a parameter list of images from a webpage and create a slideshow. I will probably change the layout and stuff like that, but right now I am just trying to get it working!!
Thanks ahead of time,
Paul