Hello,
I basically have made a little cheezy slideshow and would like to add captions to each pic as it loops through. I've tried everything I can think of. I'm assuming I might need to use an array for the string but not sure. Here is my code so far. I've included the strings I'm trying to add as variables for right now. Please have look, and I would greatly appreciate any suggestions you may have on including a string loop synced with my pics. Please and thank you:)
public class Tour extends JApplet implements Runnable
{
//*************** *************** **********insta nce variables
private Image[] loop;
private int numImages = 4;
private int currentImage = 0;
private int numStrings = 4;
private int currentString = 0;
private String caption0 = "Our Java Jive Mall Lobby";
private String caption1 = "Enjoy Family Dining at Michelle's Little Italy";
private String caption2 = "Grab lunch at Greg Bunch's Mexican Lunches";
private String caption3 = "Have Some Fun at our Java Jive Arcade";
private Thread animate = null;
private MediaTracker tracker = null;
/*************** ************oth er instance variables*/
Image loadingImage;
//*************** *************** *************** **init method
public void init()
{
loadingImage = getImage(getDoc umentBase(), "LoadingClock.g if");
tracker = new MediaTracker(th is);
loop = new Image[numImages];
for(int x = 0;x<loop.length ;x++)
{
loop[x] = getImage(getDoc umentBase(),"To ur" + x + ".jpg");
tracker.addImag e(loop[x],0);
}
animate = new Thread(this);
animate.start() ;
} //end of init()
//*************** *************** *************** ***run method
public void run()
{
try {
tracker.waitFor All();
for(;;)
{
currentImage = (currentImage + 1) % numImages;
repaint();
Thread.sleep(20 00);
}
}catch(Interrup tedException e) {
showStatus(e.to String());
}
}//end of run()
//*************** *************** *************** *paint method
public void paint(Graphics g)
{
if(tracker.chec kAll())
{
g.drawImage(loo p[currentImage],0,0,500,400,th is);
}
else
{
g.drawImage(loa dingImage,150,1 50,150,150,this );
g.drawString("T our loading...Pleas e wait...",80,65) ;
}
} //end of paint()
} //end of Tour class
I basically have made a little cheezy slideshow and would like to add captions to each pic as it loops through. I've tried everything I can think of. I'm assuming I might need to use an array for the string but not sure. Here is my code so far. I've included the strings I'm trying to add as variables for right now. Please have look, and I would greatly appreciate any suggestions you may have on including a string loop synced with my pics. Please and thank you:)
public class Tour extends JApplet implements Runnable
{
//*************** *************** **********insta nce variables
private Image[] loop;
private int numImages = 4;
private int currentImage = 0;
private int numStrings = 4;
private int currentString = 0;
private String caption0 = "Our Java Jive Mall Lobby";
private String caption1 = "Enjoy Family Dining at Michelle's Little Italy";
private String caption2 = "Grab lunch at Greg Bunch's Mexican Lunches";
private String caption3 = "Have Some Fun at our Java Jive Arcade";
private Thread animate = null;
private MediaTracker tracker = null;
/*************** ************oth er instance variables*/
Image loadingImage;
//*************** *************** *************** **init method
public void init()
{
loadingImage = getImage(getDoc umentBase(), "LoadingClock.g if");
tracker = new MediaTracker(th is);
loop = new Image[numImages];
for(int x = 0;x<loop.length ;x++)
{
loop[x] = getImage(getDoc umentBase(),"To ur" + x + ".jpg");
tracker.addImag e(loop[x],0);
}
animate = new Thread(this);
animate.start() ;
} //end of init()
//*************** *************** *************** ***run method
public void run()
{
try {
tracker.waitFor All();
for(;;)
{
currentImage = (currentImage + 1) % numImages;
repaint();
Thread.sleep(20 00);
}
}catch(Interrup tedException e) {
showStatus(e.to String());
}
}//end of run()
//*************** *************** *************** *paint method
public void paint(Graphics g)
{
if(tracker.chec kAll())
{
g.drawImage(loo p[currentImage],0,0,500,400,th is);
}
else
{
g.drawImage(loa dingImage,150,1 50,150,150,this );
g.drawString("T our loading...Pleas e wait...",80,65) ;
}
} //end of paint()
} //end of Tour class
Comment