Hello,
I'm facing the following problem:
I've two classes named Plaatje and DiaShow (see below) I want to display the
Image plaatje in the method run (which is in the class DiaShow) but it's not
working although the path is correct. What's the problem. Can someone help
me ? Thanks in advance.
Patrick
import java.io.*;
import java.awt.*;
public class Plaatje extends Canvas
{
protected Image plaatje;
protected MediaTracker tracker;
public Plaatje(File bestand) throws IOException
try
{
String bestandsnaam = bestand.getCano nicalPath();
plaatje = getToolkit().ge tImage(bestands naam);
tracker = new MediaTracker(th is);
tracker.addImag e(plaatje, 0);
tracker.waitFor ID(0);
}
catch (Exception ex)
{
throw new IOException("Pl aatjesException : " + ex);
}
}
public void paint(Graphics g)
{
g.drawImage(pla atje, 0, 0, this);
}
}
This is the method run of class DiaShow
public void run()
{
String padNaam = directoryVeld.g etText();
try
{
int slaaptijd = Integer.parseIn t(tempoVeld.get Text());
PlaatjesDirecto ry file = new PlaatjesDirecto ry(padNaam);
File[] lijst = file.bestanden( );
for (int i=0; i < lijst.length; i++)
{
textField1.setT ext(lijst[i].getPath());
labelBestand.se tText(lijst[i].getName());
Plaatje tekening = new Plaatje(lijst[i]);
tekening.setLoc ation(150, 150);
add(tekening);
try
{
Thread.sleep(sl aaptijd*1000);}
catch (InterruptedExc eption ignored){};
}
}
catch (IOException ex)
{
}
}
I'm facing the following problem:
I've two classes named Plaatje and DiaShow (see below) I want to display the
Image plaatje in the method run (which is in the class DiaShow) but it's not
working although the path is correct. What's the problem. Can someone help
me ? Thanks in advance.
Patrick
import java.io.*;
import java.awt.*;
public class Plaatje extends Canvas
{
protected Image plaatje;
protected MediaTracker tracker;
public Plaatje(File bestand) throws IOException
try
{
String bestandsnaam = bestand.getCano nicalPath();
plaatje = getToolkit().ge tImage(bestands naam);
tracker = new MediaTracker(th is);
tracker.addImag e(plaatje, 0);
tracker.waitFor ID(0);
}
catch (Exception ex)
{
throw new IOException("Pl aatjesException : " + ex);
}
}
public void paint(Graphics g)
{
g.drawImage(pla atje, 0, 0, this);
}
}
This is the method run of class DiaShow
public void run()
{
String padNaam = directoryVeld.g etText();
try
{
int slaaptijd = Integer.parseIn t(tempoVeld.get Text());
PlaatjesDirecto ry file = new PlaatjesDirecto ry(padNaam);
File[] lijst = file.bestanden( );
for (int i=0; i < lijst.length; i++)
{
textField1.setT ext(lijst[i].getPath());
labelBestand.se tText(lijst[i].getName());
Plaatje tekening = new Plaatje(lijst[i]);
tekening.setLoc ation(150, 150);
add(tekening);
try
{
Thread.sleep(sl aaptijd*1000);}
catch (InterruptedExc eption ignored){};
}
}
catch (IOException ex)
{
}
}
Comment