Name: Anonymous 2009-02-13 22:47
Any Java programmers, help me. Java is driving me fucking nuts.
I'm trying to upload and display a picture in a java applet, and for some godforsaken reason, I can't get it to work. The code is as follows:
package TestImageLoad;
import java.awt.Graphics;
import java.awt.*;
import javax.swing.*;
public class TestImageLoad extends java.applet.Applet {
Image img;
public void init() {
resize(150,150);
img = getImage(getDocumentBase(), "Picture.bmp");
}
public void paint(Graphics g) {
g.drawString("Hello world!", 10, 25);
g.drawImage(img, 10, 40, null);
}
}
The "Hello World!" is displayed, so I know the paint function is called, but either the image is not loading or it's not displaying. The file "Picture.bmp" is located in both the source directory and the one above it (the one that has the .classpath and .project). I'm using eclipse.
Good god, can someone help me with this.
I'm trying to upload and display a picture in a java applet, and for some godforsaken reason, I can't get it to work. The code is as follows:
package TestImageLoad;
import java.awt.Graphics;
import java.awt.*;
import javax.swing.*;
public class TestImageLoad extends java.applet.Applet {
Image img;
public void init() {
resize(150,150);
img = getImage(getDocumentBase(), "Picture.bmp");
}
public void paint(Graphics g) {
g.drawString("Hello world!", 10, 25);
g.drawImage(img, 10, 40, null);
}
}
The "Hello World!" is displayed, so I know the paint function is called, but either the image is not loading or it's not displaying. The file "Picture.bmp" is located in both the source directory and the one above it (the one that has the .classpath and .project). I'm using eclipse.
Good god, can someone help me with this.