home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1998 November
/
Chip_1998-11_cd.bin
/
tema
/
Cafe
/
promain.bin
/
DBVPO.DLL
/
SOURCE
/
SLIDESHOW
< prev
next >
Wrap
Text File
|
1998-03-18
|
2KB
|
104 lines
import java.awt.Button;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Panel;
import java.awt.FlowLayout;
import java.awt.Toolkit;
import java.net.URL;
import java.net.MalformedURLException;
public class SlideShow extends Panel
{
protected ImageViewer viewer;
protected String fileNames[];
protected Image images[];
protected int count;
public SlideShow()
{
try {
viewer = new ImageViewer();
setNumberOfImages(0);
} catch (Exception e)
{
}
}
public void setNumberOfImages(int i)
{
fileNames = new String[i];
images = new Image[i];
}
public int getNumberOfImages()
{
return (fileNames.length);
}
public void addFileName(String fileName)
throws MalformedURLException
{
fileNames[count] = fileName;
images[count] = getToolkit().getImage(new URL(fileNames[count]));
count++;
}
public String[] getFileNames()
{
return (fileNames);
}
public void display()
throws MalformedURLException
{
count = 0;
add(viewer);
viewer.setImage(images[count]);
}
protected void nextPressed()
{
viewer.setImage(images[++count]);
Toolkit.getDefaultToolkit().getSystemEventQueue().
postEvent(new ActionEvent((java.awt.Window)getParent(),
ActionEvent.ACTION_PERFORMED,
new Integer(count).toString()));
}
protected void prevPressed()
{
viewer.setImage(images[--count]);
Toolkit.getDefaultToolkit().getSystemEventQueue().
postEvent(new ActionEvent((java.awt.Window)getParent(),
ActionEvent.ACTION_PERFORMED,
new Integer(count).toString()));
}
public Dimension preferredSize()
{
if (viewer != null) {
Dimension d;
d = viewer.preferredSize();
return d;
}
return super.preferredSize();
}
public void repaint()
{
super.repaint();
viewer.repaint();
}
public void update(Graphics g)
{
paint(g);
}
}