Help me pls !!!
I'm having problems with my applet, it compiles & run successfully with appletviewer. However it wait forever to Loading Applet with the browser.
I have already used the HTML converter 1.3 that i downloaded from Sun's website & Java Plugin 1.3.
Pls help ...
The following is my code:-
import java.awt.*;
import java.lang.*;
import java.applet.*;
import java.net.*;
import javax.swing.*;
import java.awt.event.*;
public class SlideShow extends JApplet implements ActionListener, Runnable {
MediaTracker LoadImages;
Image slides[];
String imagefile, soundfile, type1, caption;
Thread AutoShow;
int images =0, delay=0;
int index = 0;
JButton forward, backward;
JCheckBox auto, sound;
JLabel title;
AudioClip clip;
JPanel marquee, control;
public String[][] getParameterInfo() {
String[][] info = {
{"caption", "string", "Title of the Slide Viewer"},
{"imagefile", "string", "Base Image File Name (ex. picture)"},
{"soundfile", "string", "Sound File Name (ex. audio.au)"},
{"images", "int", "Total number of image files"},
{"delay", "int", "Delay in between images (in ms.)"},
{"type", "str", "Image File Type(gif, jpg, etc)"},
};
return info;
}
public void init() {
LoadImages = new MediaTracker(this);
caption = getParameter("caption");
System.out.println(caption);
imagefile = getParameter("imagefile");
System.out.println(imagefile);
soundfile = getParameter("soundfile");
System.out.println(soundfile);
type1= getParameter("type1");
System.out.println(type1);
images = Integer.valueOf(getParameter("images")).intValue();
System.out.println(images);
slides = new Image[images];
delay= Integer.valueOf(getParameter("delay")).intValue();
System.out.println(delay);
for (int i = 0; i < images; i++) {
slides = getImage(getDocumentBase(), imagefile + i + "." + type1);
System.out.println(slides);
if (i >= 0)
LoadImages.addImage(slides, 1);
}
try {
LoadImages.waitForID(0);
} catch (InterruptedException e) {
System.out.println("Image Loading Failed!");
}
showStatus(imagefile + " Images Loaded");
index = 0;
LoadImages.checkID(1);
clip = getAudioClip(getDocumentBase(), soundfile);
Container contentPane = getContentPane();
getContentPane().setLayout(new BorderLayout());
forward = new JButton("Forward");
forward.addActionListener(this);
backward = new JButton("Backward");
backward.addActionListener(this);
auto = new JCheckBox("AutoCycle Images");
auto.setSelected(true);
sound = new JCheckBox("Sound On");
sound.setSelected(true);
sound.addActionListener(this);
title = new JLabel(caption);
marquee = new JPanel();
marquee.setLayout(new BorderLayout());
marquee.add("North", title);
control = new JPanel();
control.setLayout(new FlowLayout());
control.add(auto);
control.add(sound);
control.add(backward);
control.add(forward);
setFont(new Font("Helvetica", Font.BOLD, 18));
getContentPane().add("South", marquee);
setFont(new Font("Helvetica", Font.PLAIN, 14));
marquee.add("South", control);
}
public void actionPerformed(ActionEvent evt)
{
Object source = evt.getSource();
if (source == forward)
{
index++;
repaint();
}
else if (source == backward)
{
if (index !=0) {
index--;
repaint();
}
}
else if (source == sound)
{
if (sound.isSelected())
clip.loop();
else
clip.stop();
}
}
public void start() {
images = 0;
validate();
repaint();
clip.loop();
AutoShow = new Thread(this);
AutoShow.start();
}
public void stop() {
index = 0;
validate();
repaint();
if (AutoShow!= null) AutoShow.stop();
AutoShow= null;
}
public void run() {
Thread running = Thread.currentThread();
while (AutoShow==running) {
try {
Thread.sleep(delay);
} catch (InterruptedException e) {
break;
}
if (auto.isSelected()) {
if (LoadImages.checkID(1,true))
synchronized (this) {
if (index == (slides.length - 1))
index = 0;
else
index++;
}
invalidate();
validate();
repaint();
}
}
}
public void update(Graphics g) {
try {
paint(g);
validate();
marquee.repaint();
} catch (ArrayIndexOutOfBoundsException e) {
if(index < 0)
index = 0;
else if (index > images)
index = images;
System.out.println("No more Images!");
}
}
public void paint(Graphics g) {
if (LoadImages.isErrorAny()) {
g.setColor(Color.black);
g.fillRect(0, 0, size().width, size().height);
return;
}
g.drawImage(slides[index], 0, 0, this);
validate();
marquee.repaint();
}
}

