The Artima Developer Community
Sponsored Link

Java Answers Forum
Help Finding Slideshow Applet

1 reply on 1 page. Most recent reply: Nov 8, 2002 2:34 PM by Palani

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Red Citrus

Posts: 1
Nickname: redcitrus
Registered: Oct, 2002

Help Finding Slideshow Applet Posted: Oct 30, 2002 4:55 AM
Reply to this message Reply
Advertisement
Hello. I am desperately trying to find a java applet which can display a number of images in a slideshow or as a series of thumbnails. The problem is that I want the applet to display files from a directory where there may be any number of image files (ie. I do not want to specify as a parameter the names or number of images to be displayed - I simply want to cycle through all the images within a particular directory) Does anyone know of an applet that will allow me to do this? I know nothing about java programming, I'm afraid, so am unable to write on myself.

Cheers in advance

RedCitrus


Palani

Posts: 2
Nickname: palani
Registered: Oct, 2002

Re: Help Finding Slideshow Applet Posted: Nov 8, 2002 2:34 PM
Reply to this message Reply
Hi Red Citrus:

Have something like what you need. You can tweak it to your requirement with very minor modifications. Let me know if you need any more help. Here you go...

SlideShow Applet_______________________________________


import java.applet.Applet;

import java.awt.event.*;

import java.awt.*;





public class SlideShow extends java.applet.Applet implements Runnable{


int curSlide = 0, waitPeriod;

Image[] slides;

Thread thread;



public void init () {


String numSlidesStr = getParameter("numSlides");

String imgBase = getParameter("imgBase");

String waitPeriodStr = getParameter("waitPeriod");

int numSlides = Integer.parseInt(numSlidesStr);

waitPeriod = Integer.parseInt(waitPeriodStr);

slides = new Image[numSlides];


for ( int i=0; i < numSlides; i++ ){


String imgStr = imgBase + (i+1) + ".jpg";

slides = getImage(getCodeBase(), imgStr);

}

thread = new Thread(this);
thread.start();


}



public void run() {


while (true){


curSlide = (curSlide + 1) % slides.length;

repaint();



try{

thread.sleep(waitPeriod * 1000);

//thread.sleep(1000);

}

catch (InterruptedException e) {

break;

}

}

}



public void paint(Graphics g) {



g.drawImage(slides[curSlide], 20, 20, this);

}



public void update(Graphics g) {

// Eliminate flicker by not erasing the background

paint(g);

}


}

Flat View: This topic has 1 reply on 1 page
Topic: Java Refresh? Previous Topic   Next Topic Topic: Problem with charset

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use