Meaningless Drivel is fun!*
The moose likes Applets and the fly likes Want to Load an Image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Want to Load an Image" Watch "Want to Load an Image" New topic
Author

Want to Load an Image

Juan Ignacio
Greenhorn

Joined: Jul 02, 2007
Posts: 6
I'm trying to load an image into Image type variable for the past 2 days a get to here.

import java.awt.*;
import java.net.URL;
import java.applet.Applet;

public class Board{
//Internal Col
URL url = new URL("c:/Image/board.gif");
Image pict;
//Class Contructor
public Board(){
pict = getImage(url);
}
//an a few methods in here.
}

the error that i'm getting is:
The Method getImage(URL) is undefined for the type Board

Probably I'm missing something in the beginning, like importing something
if anyone knows which package a should import please tell me.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

The getImage() method does not exist in the class Board. That's why you are getting that exception. Since you've imported the Applet class I'll assume that's what you are trying to make. getImage() is a method of the Applet class so have Board extend Applet and try again.

Moving this to the applets forum...


GenRocket - Experts at Building Test Data
Juan Ignacio
Greenhorn

Joined: Jul 02, 2007
Posts: 6
Now is the part in Bold the one not working, when I add the "extends Applet"
to my class, I lost the import java.net.URL, why is that, there is a way to solve this?

package classes;

import java.awt.*;
import java.net.URL;
import java.applet.Applet;

public class Persona extends Applet {
//Colaboradores Internos
URL url = new URL("c:/Imagen/placa.gif");
Image foto;
String nombre;
String apellido;
String sector;
String cargo;
String horaEntrada;
String horaSalida;
char estado;
Time fyHActual = new Time();
//Contructor
public Persona (){

nombre = "Juan";
apellido = "Tibaldi";
sector = "Sistemas";
cargo = "Soporte Tecnico de Distrito Sur";
horaEntrada = fyHActual.now();
horaSalida = fyHActual.now();
estado = 'V';
foto = getImage(url);


}
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Juan Ignacio:
Now is the part in Bold the one not working, when I add the "extends Applet"
to my class, I lost the import java.net.URL, why is that, there is a way to solve this?


Yea, retype it?
Juan Ignacio
Greenhorn

Joined: Jul 02, 2007
Posts: 6
Let's do it simple anyone knows how to load an image in java.
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Want to Load an Image
 
Similar Threads
Randomly displaying images from a directory with JavaScript?
drawing on the screen in response to user-initiated actions
Using arrays to randomly generate images? (applet)
placing images in applets
Need Help Loading couple images to a BufferedImage.