| 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
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
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...
|
 |
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
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
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
|
|
|
|
 |
 |
|
|
subject: Want to Load an Image
|
|
|