[java] damn it bones I need pictures not just code

Started by
1 comment, last by thomashun 22 years, 8 months ago
I wrote the code to get a picture to pop up in an applet, I am not getting any errors and its running but no picture is coming up.
Advertisement
Are you using media tracker to make sure the image is loaded before you try and display it? Otherwise your image data will be null and the image will not ( or just partially ) display.

import java.awt.*;
import java.applet.*;
import java.awt.Image;
import java.awt.Graphics;
import java.net.URL;
import java.util.*;

public class GTest extends Applet
{
private Image im;//for displaying image line 1
private Image LEFT;

public void init()
{

im= getImage(getDocumentBase(), "CW1002.gif");
// display image line 2
LEFT = getImage(getDocumentBase(), "WALLP.jpg");



}


public void paint(Graphics g)
{
Dimension size = getSize();
setBackground(Color.black);

g.drawImage(im,350,50,this);
//display image line 3

g.drawImage(LEFT,1,1,this);

g.dispose();
}


public boolean imageUPdate(Image image, int flags, int x,
int y, int w, int h){
//display image line 4

repaint(); //display image line 5

if ((flags & ALLBITS) ==0)
return true; //** need more updates
else
return false; };//** image fully loaded
// display inage line(s) 6
}
// this code displays 2 Images (that are visible)
//this wrote comments next to the lines crucial to //displaying //image and tried to remove the non essential
//Check out Graphic Java -mastering the JFC- Volume 1 AWT
// otherwise you hit more obstacles just like this
// GL HF
"do you like my helmut?"-yoghurt

This topic is closed to new replies.

Advertisement