473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

HELP - Java-Problem

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.getCanonicalPath();
plaatje = getToolkit().getImage(bestandsnaam);
tracker = new MediaTracker(this);
tracker.addImage(plaatje, 0);
tracker.waitForID(0);
}
catch (Exception ex)
{
throw new IOException("PlaatjesException: " + ex);
}
}

public void paint(Graphics g)
{
g.drawImage(plaatje, 0, 0, this);
}
}

This is the method run of class DiaShow

public void run()
{
String padNaam = directoryVeld.getText();

try
{
int slaaptijd = Integer.parseInt(tempoVeld.getText());
PlaatjesDirectory file = new PlaatjesDirectory(padNaam);
File[] lijst = file.bestanden();
for (int i=0; i < lijst.length; i++)
{
textField1.setText(lijst[i].getPath());
labelBestand.setText(lijst[i].getName());
Plaatje tekening = new Plaatje(lijst[i]);
tekening.setLocation(150, 150);
add(tekening);
try
{
Thread.sleep(slaaptijd*1000);}
catch (InterruptedException ignored){};
}
}
catch (IOException ex)
{
}
}
Sep 17 '05 #1
2 2822
In article <43***********************@news.xs4all.nl>, "Patrick & Judith" <pm****@xs4all.nl> wrote:
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.getCanonicalPath();
plaatje = getToolkit().getImage(bestandsnaam);
tracker = new MediaTracker(this);
tracker.addImage(plaatje, 0);
tracker.waitForID(0);
}
catch (Exception ex)
{
throw new IOException("PlaatjesException: " + ex);
}
}

public void paint(Graphics g)
{
g.drawImage(plaatje, 0, 0, this);
}
}

This is the method run of class DiaShow

public void run()
{
String padNaam = directoryVeld.getText();

try
{
int slaaptijd = Integer.parseInt(tempoVeld.getText());
PlaatjesDirectory file = new PlaatjesDirectory(padNaam);
File[] lijst = file.bestanden();
for (int i=0; i < lijst.length; i++)
{
textField1.setText(lijst[i].getPath());
labelBestand.setText(lijst[i].getName());
Plaatje tekening = new Plaatje(lijst[i]);
tekening.setLocation(150, 150);
add(tekening);
try
{
Thread.sleep(slaaptijd*1000);}
catch (InterruptedException ignored){};
}
}
catch (IOException ex)
{
}
}


I don't know why it doesn't work - but you might want to display the
IOException if it's thrown instead of silently consuming it.
Sep 18 '05 #2
"Patrick & Judith" <pm****@xs4all.nl> wrote in message
news:43***********************@news.xs4all.nl...
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.


What makes you think it's not working? I.e., is there an error message?
If so, what does it say?

- Oliver
Sep 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jagdeesh | last post by:
Hai Colleagues, I am using Tomcat 4.1.24 and JDK 1.4.0_03 in my winXP machine. I've transferred a set of folders(containing jsp files) into tomcat's webapps directory(to /webapps/bob ,...
4
by: Allan Robertson | last post by:
Hello I've downloaded the Java SDK 1.4.0 from Sun's website in the hope to learning Java, however when I compile my *.java files this (at most times) works fine, however when I run the *.class...
0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
0
by: Shawn | last post by:
I am getting the following error with a Java Applet being served out by IIS over HTTPS/SSL using a Verisign certificate: java.lang.NoClassDefFoundError: javax/help/HelpSetException at...
5
by: Grant Collins | last post by:
Hi I am writing a web based application as part of a small project that I am undertaking using servlets beans and jsp. I already have one servlet - bean - jsp page working and I have written...
3
by: knightsmastergeneral | last post by:
Hi, I'm currently working on getting junit and junireport to take some java files, convert it to xml and then display error messages / success rates etc in html which is one of the features of...
0
by: yksoni | last post by:
we are working in IBM aglets 2.0.2 with mysql 4.0.2. When we try to access database through tahiti server i.e.aglets we get following error. java.net.SocketException MESSAGE:...
11
by: hamiltongreg | last post by:
I am new to Java and am having problems getting my program to compile correctly. My assignment is as follows; Choose a product that lends itself to an inventory (for example, products at your...
5
by: saytri | last post by:
Hi i have this project were i have to do a quiz. i wrote the questions in a textfile and i called them through java. I have also made a menu to choose which type of quiz. But before accessing the...
3
by: prashfire2000 | last post by:
This is a code i wrote to play a video file usin JMF..... the applet gets started but not initialized..... is the code correct or is there any mistake?????? please help me out as soon as u...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.